Micron Document
<!DOCTYPE html>
<html class="client-nojs vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-0 vector-toc-not-available vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-0 vector-feature-night-mode-enabled skin-theme-clientpref-os vector-sticky-header-enabled" lang="fr" dir="ltr"><head>
<meta charset="UTF-8">
<title>JavaScript</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="./_res_/favicon.png">
<link rel="canonical" href="https://fr.wikipedia.org/wiki/JavaScript"> <link href="./_mw_/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./_mw_/ext.pygments.css" rel="stylesheet" type="text/css">
<link href="./_mw_/ext.wikimediamessages.styles.css" rel="stylesheet" type="text/css">
<link href="./_mw_/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./_mw_/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./_mw_/skins.vector.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./_mw_/site.styles.css">
<link rel="stylesheet" type="text/css" href="./_mw_/noscript.css">
<link rel="stylesheet" type="text/css" href="./_res_/footer.css">
<link rel="stylesheet" type="text/css" href="./_res_/vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-JavaScript rootpage-JavaScript skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading"><span class="mw-page-title-main">JavaScript</span></h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="contentSub">
<div id="mw-content-subtitle"></div>
</div>
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="fr" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="fr" dir="ltr">
<p class="mw-empty-elt">
</p>
<table class="infobox_v2 infobox infobox--frwiki noarchive">
<tbody><tr>
<td colspan="2" class="entete informatique" style="background-color:#f7df1e;color:black;">JavaScript<style data-mw-deduplicate="TemplateStyles:r228712691">
/* start https://fr.wikipedia.org/ */


.mw-parser-output .entete.informatique{background-image:url("./_mw_/Picto.nfo.png")}


/* end https://fr.wikipedia.org/ */
</style>
</td></tr>
<tr><td colspan="3" style="text-align:center; line-height: 1.5em;"> </td></tr>
<tr>
<td colspan="3" style="text-align:center; line-height: 1.5em;"> <br>Capture d'écran d'une page HTML contenant du code JavaScript.</td></tr>
<tr>
<td colspan="2"><hr style="height:2px; color:inherit; background-color:#f7df1e;"></td></tr>
<tr>
<th scope="row">Date de première version
</th>
<td><span class="wd_p571"><time class="nowrap date-lien" datetime="1996-05" data-sort-value="1996-05"><a href="Mai_1996" title="Mai 1996">Mai</a> <a href="1996" title="1996">1996</a></time></span>
</td>
</tr>
<tr>

<th scope="row"><a href="Paradigme_(programmation)" title="Paradigme (programmation)">Paradigmes</a>
</th>
<td><a href="Langage_de_script" title="Langage de script">script</a>, <a href="Programmation_orient%C3%A9e_objet" title="Programmation orientée objet">orienté objet</a> (<a href="Programmation_orient%C3%A9e_prototype" title="Programmation orientée prototype">orienté prototype</a>), <a href="Programmation_imp%C3%A9rative" title="Programmation impérative">impératif</a>, <a href="Programmation_fonctionnelle" title="Programmation fonctionnelle">fonctionnel</a>
</td>
</tr>
<tr>
<th scope="row">Auteur
</th>
<td><a href="Brendan_Eich" title="Brendan Eich">Brendan Eich</a>
</td>
</tr>
<tr>


<th scope="row">Développeurs
</th>
<td><a href="Netscape_Communications_Corporation" class="mw-redirect" title="Netscape Communications Corporation">Netscape Communications Corporation</a>, <a href="Mozilla_Foundation" title="Mozilla Foundation">Mozilla Foundation</a>
</td>
</tr>
<tr>
<th scope="row"><a href="Version_d'un_logiciel" title="Version d'un logiciel">Dernière version</a>
</th>
<td>13 - ECMA-262 (Juin 2022)
</td>
</tr>
<tr>
<th scope="row"><a href="Version_d'un_logiciel" title="Version d'un logiciel">Version en développement</a>
</th>
<td><span class="wd_p348">ECMAScript 2025 (<time class="nowrap date-lien" datetime="2024-03-27" data-sort-value="2024-03-27"><a href="27_mars" title="27 mars">27</a> <a href="Mars_2024" title="Mars 2024">mars</a> <a href="2024" title="2024">2024</a></time>)<sup id="cite_ref-wikidata-6351048ad5638805e5935d8ba81b639a34072b65_2-0" class="reference"><a href="#cite_note-wikidata-6351048ad5638805e5935d8ba81b639a34072b65-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup></span>
</td>
</tr>
<tr>
<th scope="row">Typage
</th>
<td><a href="Typage_dynamique" title="Typage dynamique">dynamique</a>, <a href="Typage_faible" class="mw-redirect" title="Typage faible">faible</a>
</td>
</tr>
<tr>
<th scope="row"><a href="Norme" title="Norme">Normes</a>
</th>
<td>ECMA-262<br>ISO/CEI 16262
</td>
</tr>
<tr>
<th scope="row">Dialectes
</th>
<td>JavaScript, <a href="JScript" title="JScript">JScript</a>, <a href="ECMAScript" title="ECMAScript">ECMAScript</a>
</td>
</tr>
<tr>
<th scope="row">Influencé par
</th>
<td><a href="Awk" title="Awk"> AWK</a>, <a href="Self_(langage)" title="Self (langage)">Self</a>, <a href="Scheme" title="Scheme">Scheme</a><sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup>, <a href="Perl_(langage)" title="Perl (langage)">Perl</a>, <a href="C_(langage)" title="C (langage)">C</a>, <a href="C%2B%2B" title="C++">C++</a>, <a href="Java_(langage)" title="Java (langage)">Java</a>, <a href="Python_(langage)" title="Python (langage)">Python</a>
</td>
</tr>
<tr>
<th scope="row">A influencé
</th>
<td><a href="JScript" title="JScript">JScript</a>, <a href="JScript_.NET" title="JScript .NET">JScript .NET</a>, <a href="Objective-J" title="Objective-J">Objective-J</a>, TIScript
</td>
</tr>
<tr>
<th scope="row">Implémentations
</th>
<td><a href="SpiderMonkey" title="SpiderMonkey">SpiderMonkey</a>, <a href="Rhino_(moteur_JavaScript)" title="Rhino (moteur JavaScript)">Rhino</a>, KJS, <a href="JavaScriptCore" title="JavaScriptCore">JavaScriptCore</a>, <a href="V8_(moteur_JavaScript)" title="V8 (moteur JavaScript)">V8</a>
</td>
</tr>
<tr>




<th scope="row"><a href="Site_web" title="Site web">Site web</a>
</th>
<td><a rel="nofollow" class="external text" href="https://developer.mozilla.org/fr/JavaScript">Mozilla</a>
</td>
</tr>
<tr>
<th scope="row"><a href="Extension_de_nom_de_fichier" title="Extension de nom de fichier">Extension de fichier</a>
</th>
<td><span class="wd_p1195">js et mjs</span>
</td>
</tr>
<tr>

</tr>
</tbody></table>
<p><b>JavaScript</b> est un <a href="Langage_de_programmation" title="Langage de programmation">langage de programmation</a> de <a href="Langage_de_script" title="Langage de script">scripts</a> principalement employé dans les <a href="Page_web" title="Page web">pages web</a> interactives et à ce titre est une partie essentielle des <a href="Application_web" title="Application web">applications web</a>. Avec les langages <a href="Hypertext_Markup_Language" title="Hypertext Markup Language">HTML</a> et <a href="Feuilles_de_style_en_cascade" title="Feuilles de style en cascade">CSS</a>, JavaScript est au cœur des langages utilisés par les <a href="D%C3%A9veloppeur_web" title="Développeur web">développeurs web</a><sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup>. Une grande majorité des <a href="Site_web" title="Site web">sites web</a> l'utilisent<sup id="cite_ref-deployedstats_5-0" class="reference"><a href="#cite_note-deployedstats-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup> et la majorité des <a href="Navigateur_web" title="Navigateur web">navigateurs web</a> disposent d'un <a href="Moteur_JavaScript" title="Moteur JavaScript">moteur JavaScript</a><sup id="cite_ref-6" class="reference"><a href="#cite_note-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup> pour l'<a href="Interpr%C3%A8te_(informatique)" title="Interprète (informatique)">interpréter</a>.
</p><p>JavaScript est aussi employé pour les <a href="Serveurs_Web" class="mw-redirect" title="Serveurs Web">serveurs Web</a><sup id="cite_ref-7" class="reference"><a href="#cite_note-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup> avec l'utilisation (par exemple) de <a href="Node.js" title="Node.js">Node.js</a><sup id="cite_ref-8" class="reference"><a href="#cite_note-8"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup> ou de <a href="Deno_(logiciel)" title="Deno (logiciel)">Deno</a><sup id="cite_ref-9" class="reference"><a href="#cite_note-9"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup>.
</p><p>JavaScript a été créé en 1995 par <a href="Brendan_Eich" title="Brendan Eich">Brendan Eich</a> et intégré au <a href="Navigateur_web" title="Navigateur web">navigateur web</a> <a href="Netscape_Navigator" title="Netscape Navigator">Netscape Navigator</a> 2.0. L'implémentation concurrente de JavaScript par <a href="Microsoft" title="Microsoft">Microsoft</a> dans <a href="Internet_Explorer" title="Internet Explorer">Internet Explorer</a>, jusqu'à sa version 9, se nommait <a href="JScript" title="JScript">JScript</a>, tandis que celle d'<a href="Adobe_Systems" class="mw-redirect" title="Adobe Systems">Adobe Systems</a> se nommait <a href="ActionScript" title="ActionScript">ActionScript</a>. JavaScript a été standardisé sous le nom d'<a href="ECMAScript" title="ECMAScript">ECMAScript</a> en <time class="nowrap" datetime="1997-06" data-sort-value="1997-06">juin 1997</time> par <a href="Ecma_International" title="Ecma International">Ecma International</a> dans le standard ECMA-262. La version en vigueur de ce standard depuis juin 2022 est la 13<sup>e</sup> édition.
</p><p>C'est un langage <a href="Orient%C3%A9_objet" class="mw-redirect" title="Orienté objet">orienté objet</a> à <a href="Programmation_orient%C3%A9e_prototype" title="Programmation orientée prototype">prototype</a>&nbsp;: les bases du langage et ses principales <a href="Interface_de_programmation" title="Interface de programmation">interfaces</a> sont fournies par des <a href="Objet_(informatique)" title="Objet (informatique)">objets</a>. Cependant, à la différence d'un langage orienté objets à classes, les objets de base ne sont pas des <a href="Instance_(programmation)" title="Instance (programmation)">instances</a> de <a href="Classe_(informatique)" title="Classe (informatique)">classes</a>. En outre, les <a href="Routine_(informatique)" title="Routine (informatique)">fonctions</a> sont des <a href="Objet_de_premi%C3%A8re_classe" title="Objet de première classe">objets de première classe</a>. Le langage supporte le <a href="Paradigme_de_programmation" class="mw-redirect" title="Paradigme de programmation">paradigme</a> <a href="Programmation_objet" class="mw-redirect" title="Programmation objet">objet</a>, <a href="Programmation_imp%C3%A9rative" title="Programmation impérative">impératif</a> et <a href="Programmation_fonctionnelle" title="Programmation fonctionnelle">fonctionnel</a>.
</p><p>JavaScript est le langage possédant le plus large <a href="https://fr.wiktionary.org/wiki/%C3%A9cosyst%C3%A8me" class="extiw external" title="wikt:écosystème">écosystème</a> grâce à son gestionnaire de dépendances <a href="Npm" title="Npm">npm</a>, avec plus de deux millions de paquets en <time class="nowrap" datetime="2022-09" data-sort-value="2022-09">septembre 2022</time><sup id="cite_ref-10" class="reference"><a href="#cite_note-10"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup>.
</p>

<div class="mw-heading mw-heading2"><h2 id="Histoire">Histoire</h2></div>
<div class="mw-heading mw-heading3"><h3 id="Début"><span id="D.C3.A9but"></span>Début</h3></div>
<p>Le langage a été créé en dix jours, en mai <a href="1995" title="1995">1995</a>, pour le compte de la <a href="Netscape_Communications_Corporation" class="mw-redirect" title="Netscape Communications Corporation">Netscape Communications Corporation</a> par <a href="Brendan_Eich" title="Brendan Eich">Brendan Eich</a>. Il s'est inspiré de nombreux langages, notamment de <a href="Java_(langage)" title="Java (langage)">Java</a>, en simplifiant la <a href="Syntaxe_JavaScript" title="Syntaxe JavaScript">syntaxe</a> pour les débutants<sup id="cite_ref-11" class="reference"><a href="#cite_note-11"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup>. <a href="Brendan_Eich" title="Brendan Eich">Brendan Eich</a> a initialement développé un langage de script côté serveur, appelé LiveScript, pour renforcer l'offre commerciale de <a href="Serveur_HTTP" class="mw-redirect" title="Serveur HTTP">serveur HTTP</a>. Netscape travaille alors au développement d'une version orientée client de LiveScript.
</p><p>Quelques jours avant sa sortie, Netscape change le nom de LiveScript pour JavaScript. <a href="Sun_Microsystems" title="Sun Microsystems">Sun Microsystems</a> et Netscape étaient partenaires, et la <a href="Machine_virtuelle" title="Machine virtuelle">machine virtuelle</a> <a href="Java_(langage)" title="Java (langage)">Java</a> de plus en plus populaire. Ce changement de nom servait les intérêts des deux sociétés. Le <time class="nowrap" datetime="1995-12-04" data-sort-value="1995-12-04">4 décembre 1995</time> <a href="Netscape_Communications" title="Netscape Communications">Netscape</a> et <a href="Sun_Microsystems" title="Sun Microsystems">Sun Microsystems</a> annoncent<sup id="cite_ref-newsrelease67_12-0" class="reference"><a href="#cite_note-newsrelease67-12"><span class="cite-bracket">[</span>12<span class="cite-bracket">]</span></a></sup> la sortie de JavaScript, décrit comme un complément à <a href="Java_(langage)" title="Java (langage)">Java</a>, dans un <a href="Communiqu%C3%A9_de_presse" title="Communiqué de presse">communiqué de presse</a> commun. Cette initiative a contribué à créer auprès du public une certaine confusion entre les deux langages, proches syntaxiquement mais pas du tout dans leurs concepts fondamentaux, et qui perdure encore de nos jours.
</p><p>En <time class="nowrap" datetime="1996-03" data-sort-value="1996-03">mars 1996</time>, Netscape met en œuvre le <a href="Moteur_JavaScript" title="Moteur JavaScript">moteur JavaScript</a> dans son <a href="Navigateur_web" title="Navigateur web">navigateur web</a> <a href="Netscape_Navigator" title="Netscape Navigator">Netscape Navigator</a> 2.0. Le succès de ce navigateur contribue à l'adoption rapide de JavaScript dans le développement web orienté client. <a href="Microsoft" title="Microsoft">Microsoft</a> réagit alors en développant <a href="JScript" title="JScript">JScript</a>, qu'il inclut ensuite dans <a href="Internet_Explorer" title="Internet Explorer">Internet Explorer</a> 3.0 en <time class="nowrap" datetime="1996-08" data-sort-value="1996-08">août 1996</time> pour la sortie de son navigateur.
</p><p>« JavaScript » devient une <a href="Marque_d%C3%A9pos%C3%A9e" class="mw-redirect" title="Marque déposée">marque déposée</a> par <a href="Sun_Microsystems" title="Sun Microsystems">Sun Microsystems</a> aux <a href="%C3%89tats-Unis" title="États-Unis">États-Unis</a> en <time class="nowrap" datetime="1997-05" data-sort-value="1997-05">mai 1997</time><sup id="cite_ref-13" class="reference"><a href="#cite_note-13"><span class="cite-bracket">[</span>13<span class="cite-bracket">]</span></a></sup><sup class="reference cite_virgule">,</sup><sup id="cite_ref-14" class="reference"><a href="#cite_note-14"><span class="cite-bracket">[</span>14<span class="cite-bracket">]</span></a></sup>.
</p>
<div class="mw-heading mw-heading2"><h2 id="Marque_déposée"><span id="Marque_d.C3.A9pos.C3.A9e"></span>Marque déposée</h2></div>
<p>"JavaScript" est une <a href="Marque_d%C3%A9pos%C3%A9e" class="mw-redirect" title="Marque déposée">marque déposée</a> d'<a href="Oracle_Corporation" class="mw-redirect" title="Oracle Corporation">Oracle Corporation</a> aux États-Unis<sup id="cite_ref-15" class="reference"><a href="#cite_note-15"><span class="cite-bracket">[</span>15<span class="cite-bracket">]</span></a></sup><sup class="reference cite_virgule">,</sup><sup id="cite_ref-16" class="reference"><a href="#cite_note-16"><span class="cite-bracket">[</span>16<span class="cite-bracket">]</span></a></sup>. À l'origine, la marque a été attribuée à <a href="Sun_Microsystems" title="Sun Microsystems">Sun Microsystems</a> le 6 mai 1997, puis transférée à Oracle lors de leur acquisition de Sun en 2009<sup id="cite_ref-17" class="reference"><a href="#cite_note-17"><span class="cite-bracket">[</span>17<span class="cite-bracket">]</span></a></sup><sup class="reference cite_virgule">,</sup><sup id="cite_ref-18" class="reference"><a href="#cite_note-18"><span class="cite-bracket">[</span>18<span class="cite-bracket">]</span></a></sup><sup class="reference cite_virgule">,</sup><sup id="cite_ref-19" class="reference"><a href="#cite_note-19"><span class="cite-bracket">[</span>19<span class="cite-bracket">]</span></a></sup>.
</p>
<div class="mw-heading mw-heading3"><h3 id="Standardisation">Standardisation</h3></div>
<p>Netscape soumet alors JavaScript à <a href="Ecma_International" title="Ecma International">Ecma International</a> pour standardisation.
</p>
<div class="mw-heading mw-heading4"><h4 id="Version_1_:_Naissance_du_standard_ECMA-262">Version 1&nbsp;: Naissance du standard ECMA-262</h4></div>
<p>Les travaux débutent en <time class="nowrap" datetime="1996-11" data-sort-value="1996-11">novembre 1996</time> et se terminent en <time class="nowrap" datetime="1997-06" data-sort-value="1997-06">juin 1997</time>, donnant naissance à la <abbr class="abbr" title="Première">1<sup>re</sup></abbr>&nbsp;édition du standard ECMA-262 qui spécifie le langage <a href="ECMAScript" title="ECMAScript">ECMAScript</a> d'où le fait que le n° ou l'année de la version est souvent précédée par <i>ECMAScript</i> ou en abrégé <i>ES</i>.
Le standard est ensuite soumis à l'<a href="Organisation_internationale_de_normalisation" title="Organisation internationale de normalisation">ISO/CEI</a> et publié en <time class="nowrap" datetime="1998-04" data-sort-value="1998-04">avril 1998</time> en tant que standard international ISO/CEI 16262.
</p>
<div class="mw-heading mw-heading4"><h4 id="Version_2_:_Homogénéisation_avec_le_standard_ISO/CEI_16262"><span id="Version_2_:_Homog.C3.A9n.C3.A9isation_avec_le_standard_ISO.2FCEI_16262"></span>Version 2&nbsp;: Homogénéisation avec le standard ISO/CEI 16262</h4></div>
<p>Des changements rédactionnels sont apportés au standard ECMA-262 pour le conformer au standard international ISO/CEI 16262, aboutissant à la <abbr class="abbr" title="Deuxième">2<sup>e</sup></abbr>&nbsp;édition du standard ECMA-262 en <time class="nowrap" datetime="1998-06" data-sort-value="1998-06">juin 1998</time>.
</p>
<div class="mw-heading mw-heading4"><h4 id="Version_3_:_Améliorations_et_constitution_du_langage"><span id="Version_3_:_Am.C3.A9liorations_et_constitution_du_langage"></span>Version 3&nbsp;: Améliorations et constitution du langage</h4></div>
<p>La <abbr class="abbr" title="Troisième">3<sup>e</sup></abbr>&nbsp;édition du standard ECMA-262 introduit&nbsp;:
</p>
<ul><li>des <a href="Expression_r%C3%A9guli%C3%A8re" title="Expression régulière">expressions rationnelles</a> plus puissantes&nbsp;;</li>
<li>une amélioration de la manipulation des <a href="Cha%C3%AEne_de_caract%C3%A8res" title="Chaîne de caractères">chaînes de caractères</a>&nbsp;;</li>
<li>de nouvelles instructions de contrôle&nbsp;;</li>
<li>une gestion des exceptions avec les instructions try/catch&nbsp;;</li>
<li>le formatage des nombres.</li></ul>
<p>Elle est publiée par Ecma International en <time class="nowrap" datetime="1999-12" data-sort-value="1999-12">décembre 1999</time> puis soumise à l'ISO/CEI qui publie le standard international ISO/CEI 16262:2002 en <time class="nowrap" datetime="2002-06" data-sort-value="2002-06">juin 2002</time>. Après la publication de la <abbr class="abbr" title="Troisième">3<sup>e</sup></abbr>&nbsp;édition s'ensuit une adoption massive par tous les navigateurs Web.
</p>
<div class="mw-heading mw-heading4"><h4 id="Version_4_:_L'étape_inachevée"><span id="Version_4_:_L.27.C3.A9tape_inachev.C3.A9e"></span>Version 4&nbsp;: L'étape inachevée</h4></div>
<p>Un travail important est entrepris pour développer la <abbr class="abbr" title="Quatrième">4<sup>e</sup></abbr>&nbsp;édition du standard ECMA-262, mais il ne sera pas achevé et cette édition ne verra jamais le jour. Cependant une partie du développement effectué sera intégrée à la <abbr class="abbr" title="Sixième">6<sup>e</sup></abbr>&nbsp;édition.
</p>
<div class="mw-heading mw-heading4"><h4 id="Version_5_:_Désambiguïsation_et_nouvelles_fonctionnalités"><span id="Version_5_:_D.C3.A9sambigu.C3.AFsation_et_nouvelles_fonctionnalit.C3.A9s"></span>Version 5&nbsp;: Désambiguïsation et nouvelles fonctionnalités</h4></div>
<p>La <abbr class="abbr" title="Cinquième">5<sup>e</sup></abbr>&nbsp;édition du standard ECMA-262 clarifie les ambiguïtés de la <abbr class="abbr" title="Troisième">3<sup>e</sup></abbr>&nbsp;édition et introduit les accesseurs, l'introspection, le contrôle des attributs, des fonctions de manipulation de tableaux supplémentaires, le support du format <a href="JavaScript_Object_Notation" title="JavaScript Object Notation">JSON</a> et un mode strict pour la vérification des erreurs. Elle est publiée par Ecma International en <time class="nowrap" datetime="2009-12" data-sort-value="2009-12">décembre 2009</time> puis soumise à l'ISO/CEI qui apporte des corrections mineures et publie le standard international ISO/CEI 16262:2011 en <time class="nowrap" datetime="2011-06" data-sort-value="2011-06">juin 2011</time>. L'édition 5.1 du standard ECMA-262 reprenant à l'identique le texte du standard international ISO/CEI 16262:2011 est publiée à la même date.
</p>
<div class="mw-heading mw-heading4"><h4 id="Version_6_(ES6)_-_ECMAScript_2015_:_Amélioration_du_support_et_des_fonctionnalités"><span id="Version_6_.28ES6.29_-_ECMAScript_2015_:_Am.C3.A9lioration_du_support_et_des_fonctionnalit.C3.A9s"></span>Version 6 (ES6) - ECMAScript 2015&nbsp;: Amélioration du support et des fonctionnalités</h4></div>
<p>Bien que le développement de la <abbr class="abbr" title="Sixième">6<sup>e</sup></abbr>&nbsp;édition du standard ECMA-262 ait commencé officiellement en 2009, peu avant la publication de la <abbr class="abbr" title="Cinquième">5<sup>e</sup></abbr>&nbsp;édition, sa publication en <time class="nowrap" datetime="2015-06" data-sort-value="2015-06">juin 2015</time> est en réalité l'aboutissement de 15 ans de travail depuis la publication de la <abbr class="abbr" title="Troisième">3<sup>e</sup></abbr>&nbsp;édition en 1999. Le but de cette <abbr class="abbr" title="Sixième">6<sup>e</sup></abbr>&nbsp;édition est d'apporter un meilleur support pour les applications d'envergure, la création de bibliothèques et l'utilisation d'ECMAScript comme cible de <a href="Compilateur" title="Compilateur">compilation</a> pour d'autres langages. Cette édition introduit notamment les modules, les classes, la portée lexicale au niveau des blocs, les itérateurs et les générateurs, les promesses pour la programmation asynchrone, les patrons de déstructuration, l'optimisation des appels terminaux, de nouvelles <a href="Structure_de_donn%C3%A9es" title="Structure de données">structures de données</a> (<a href="Tableau_associatif" title="Tableau associatif">tableaux associatifs</a>, <a href="Ensemble" title="Ensemble">ensembles</a>, tableaux binaires), le support de caractères <a href="Unicode" title="Unicode">Unicode</a> supplémentaires dans les chaînes de caractères et les expressions rationnelles et la possibilité d'étendre les structures de données prédéfinies. À partir de cette version, l'intitulé officiel de la version est ECMAScript&nbsp;2015 (année de parution)<sup id="cite_ref-20" class="reference"><a href="#cite_note-20"><span class="cite-bracket">[</span>20<span class="cite-bracket">]</span></a></sup>.
</p>
<div class="mw-heading mw-heading4"><h4 id="Version_7_-_ECMAScript_2016_:_une_adaptation_permanente_aux_outils_du_web">Version 7 - ECMAScript 2016&nbsp;: une adaptation permanente aux outils du web</h4></div>
<p>La <abbr class="abbr" title="Septième">7<sup>e</sup></abbr>&nbsp;édition du standard ECMA-262 est la première édition issue du nouveau processus de développement ouvert et du rythme de publication annuel adoptés par le comité Ecma TC39. Un document au format texte est créé à partir de la <abbr class="abbr" title="Sixième">6<sup>e</sup></abbr>&nbsp;édition et est mis en ligne sur <a href="GitHub" title="GitHub">GitHub</a> comme base de développement pour cette nouvelle édition. Après la correction de milliers de bugs et d'erreurs rédactionnelles ainsi que l'introduction de l'opérateur d'exponentiation et d'une nouvelle méthode pour les prototypes de tableaux, la <abbr class="abbr" title="Septième">7<sup>e</sup></abbr>&nbsp;édition est publiée en <time class="nowrap" datetime="2016-06" data-sort-value="2016-06">juin 2016</time>.
</p>
<div class="mw-heading mw-heading4"><h4 id="Version_8_(ES8)_-_ECMAScript_2017:_Asynchronicité"><span id="Version_8_.28ES8.29_-_ECMAScript_2017:_Asynchronicit.C3.A9"></span>Version 8 (ES8) - ECMAScript 2017: Asynchronicité</h4></div>
<p>L'apport majeur concerne les <a href="Syst%C3%A8me_asynchrone" title="Système asynchrone">fonctions asynchrones</a>.
</p><p>On retrouve également&nbsp;:
</p>
<ul><li>Le partage de mémoire entre différents fil d'exécution et workers (Shared memory and atomics)</li>
<li>Les fonctions <code>Object.values()</code> et <code>Object.entries()</code> qui permettent de faciliter la manipulation des objets.</li></ul>
<p>L'édition actuelle du standard ECMA-262 est la <abbr class="abbr" title="Treizième">13<sup>e</sup></abbr> édition publiée en juin 2022<sup id="cite_ref-21" class="reference"><a href="#cite_note-21"><span class="cite-bracket">[</span>21<span class="cite-bracket">]</span></a></sup>.
</p>
<div class="mw-heading mw-heading2"><h2 id="Sécurité"><span id="S.C3.A9curit.C3.A9"></span>Sécurité</h2></div>
<p>JavaScript et la structure <a href="Document_Object_Model" title="Document Object Model">DOM</a> des pages <a href="Hypertext_Markup_Language" title="Hypertext Markup Language">HTML</a>/<a href="Extensible_Markup_Language" title="Extensible Markup Language">XML</a> ont quelques <a href="Vuln%C3%A9rabilit%C3%A9_(informatique)" title="Vulnérabilité (informatique)">failles de sécurité</a>. En effet, des <a href="Programme_informatique" title="Programme informatique">scripts</a> malveillants peuvent se cacher dans le code d'une page web et s'exécuter sur l'ordinateur cible de l'utilisateur du Web.
</p><p>Les problèmes de sécurité étaient souvent présents avec <a href="ActiveX" title="ActiveX">ActiveX</a>, une fonctionnalité du navigateur maintenant obsolète <a href="Internet_Explorer" title="Internet Explorer">Internet Explorer</a>. Cette fonctionnalité permettait l'exécution de programmes malveillants sur l'ordinateur de la victime, en dehors du navigateur. Aujourd'hui, l'environnement javascript est plus sécurisé.
</p><p>Les fournisseurs de <a href="Navigateur_web" title="Navigateur web">navigateurs web</a> tentent de réduire ce risque avec deux restrictions&nbsp;:
</p>
<ul><li>l'une est de faire exécuter ces scripts dans un espace à part des autres données (<a href="Sandbox_(s%C3%A9curit%C3%A9_informatique)" title="Sandbox (sécurité informatique)">sandbox</a>) dans lequel seules des actions relatives au web (mouvements de souris, affichage de <a href="Pixel" title="Pixel">pixel</a>, communications) peuvent être exécutées, sans avoir accès au <a href="Syst%C3%A8me_de_fichiers" title="Système de fichiers">système de fichier</a> principal&nbsp;;</li>
<li>la deuxième est de n'exécuter les scripts que selon les contraintes de <a href="Same-origin_policy" title="Same-origin policy">same-origin policy</a>&nbsp;: dans cet esprit, un site Web ne doit pas avoir accès aux informations telles que les noms d'utilisateur et mot de passe ou <a href="Cookie_(informatique)" title="Cookie (informatique)">cookies</a> reçus des autres sites visités.</li></ul>
<p>Les vulnérabilités de JavaScript sont bien souvent des brèches d'au moins l'un de ces deux principes.
</p><p>Certains sous-ensembles du langage Javascript tels que JavaScript—ADsafe ou Secure ECMAScript (SES) fournissent de plus grands niveaux de sécurité, en particulier pour les scripts créés par des tierces parties (notamment les publicités)<sup id="cite_ref-22" class="reference"><a href="#cite_note-22"><span class="cite-bracket">[</span>22<span class="cite-bracket">]</span></a></sup><sup class="reference cite_virgule">,</sup><sup id="cite_ref-23" class="reference"><a href="#cite_note-23"><span class="cite-bracket">[</span>23<span class="cite-bracket">]</span></a></sup>. Caja est un autre logiciel pour inclure et isoler de manière sécurisée du JavaScript et du HTML tierce partie.
</p><p>La <a href="Content_Security_Policy" title="Content Security Policy">Politique de sécurité du contenu</a> est la principale méthode destinée à assurer que seul un script de confiance est exécuté sur une page Web. <a href="Meltdown_(vuln%C3%A9rabilit%C3%A9)" title="Meltdown (vulnérabilité)">Meltdown</a> est une vulnérabilité indépendante de Javascript, qui peut notamment être exploitée en Javascript.
</p>
<div class="mw-heading mw-heading2"><h2 id="Concepts_de_programmation">Concepts de programmation</h2></div>
<p>Le propos de JavaScript est de manipuler de façon simple des <a href="Programmation_orient%C3%A9e_objet" title="Programmation orientée objet">objets</a>, au sens informatique, fournis par une application hôte. Par exemple dans un navigateur web, un script écrit en javascript peut être utilisé pour apporter une touche interactive ou dynamique à un applicatif (page ou site web), qui sans cela serait une page statique figée. Le langage Javascript permet par exemple d'écrire des scripts pour afficher ou cacher un paragraphe, une image ou un <a href="Pop-up" title="Pop-up">popup</a>, selon les interactions de l'utilisateur, ou d'informer le serveur du temps passé à lire une page.
</p>
<div class="mw-heading mw-heading3"><h3 id="Hello_world">Hello world</h3></div>
<p>Il est possible dans un script en langage Javascript, d'afficher le texte <i><a href="Hello_world" title="Hello world">hello world</a></i> sur la console de debug de l’application. Ceci peut être utilisé par des développeurs en phase de mise au point<sup id="cite_ref-24" class="reference"><a href="#cite_note-24"><span class="cite-bracket">[</span>24<span class="cite-bracket">]</span></a></sup>.&nbsp;:
</p>
<div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="nb">window</span><span class="p">.</span><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">'Hello world'</span><span class="p">);</span><span class="w"> </span><span class="nb">window</span><span class="p">.</span><span class="nx">console</span><span class="p">.</span><span class="nx">exp</span><span class="p">(</span><span class="nx">hello</span><span class="w"> </span><span class="nx">world</span><span class="p">)</span>
<span class="c1">// ou</span>
<span class="nb">global</span><span class="p">.</span><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">'Hello world'</span><span class="p">);</span><span class="w"> </span><span class="nb">window</span><span class="p">.</span><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">hello</span><span class="w"> </span><span class="nx">world</span><span class="p">)</span>
</pre></div>
<p>Dans une application hôte d'un navigateur, <i>console</i> est une des méthodes de l'objet global <i>window</i><sup id="cite_ref-25" class="reference"><a href="#cite_note-25"><span class="cite-bracket">[</span>25<span class="cite-bracket">]</span></a></sup><i>.</i> Dans d'autres applications hôtes comme <a href="Node.js" title="Node.js">Node.js</a>, l'objet global est <i>global</i><sup id="cite_ref-26" class="reference"><a href="#cite_note-26"><span class="cite-bracket">[</span>26<span class="cite-bracket">]</span></a></sup>. Les méthodes de l'objet global étant accessibles sans préfixe, <i>window</i> et <i>global</i> sont facultatifs.
</p><p>
La syntaxe </p><div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">'Hello world'</span><span class="p">);</span>
</pre></div><p> aura donc exactement le même résultat en plus d'être compatible sur tous les environnements.
</p><div class="mw-heading mw-heading2"><h2 id="Utilisation">Utilisation</h2></div>
<p>Le code JavaScript a besoin d'un <i>objet global</i> pour y rattacher les <a href="D%C3%A9claration_(informatique)" title="Déclaration (informatique)">déclarations</a> (<a href="Variable_(informatique)" title="Variable (informatique)">variables</a> et <a href="Routine_(informatique)" title="Routine (informatique)">fonctions)</a> avant d'exécuter des instructions. La situation la plus connue est celle de l'objet <i>window</i> obtenu dans le contexte d'une <a href="Page_web" title="Page web">page web</a>. D'autres environnements sont possibles dont celui fourni par <a href="Adobe_(entreprise)" title="Adobe (entreprise)">Adobe</a> ou l'environnement <a href="Node.js" title="Node.js">Node.js</a> (voir plus bas Autres utilisations).
</p><p>Les principaux domaines d'application de JavaScript sont avant tout la programmation, les activités de programmation de base et tout ce qui est lié à l'informatique.
</p>
<div class="mw-heading mw-heading3"><h3 id="Dans_une_page_web">Dans une page web</h3></div>
<p>Du code JavaScript peut être intégré directement au sein des <a href="Page_web" title="Page web">pages web</a>, pour y être exécuté sur le poste <a href="Client-serveur" title="Client-serveur">client</a>. C'est alors le <a href="Navigateur_web" title="Navigateur web">navigateur web</a> qui prend en charge l'exécution de ces programmes appelés scripts.
</p><p>Généralement, JavaScript sert à contrôler les données saisies dans des formulaires <a href="Hypertext_Markup_Language" title="Hypertext Markup Language">HTML</a>, ou à interagir avec le document HTML <i>via</i> l'interface <a href="Document_Object_Model" title="Document Object Model">Document Object Model</a>, fournie par le navigateur (on parle alors parfois de <a href="HTML_dynamique" title="HTML dynamique">HTML dynamique</a> ou DHTML). Il est aussi utilisé pour réaliser des applications dynamiques, des transitions, des animations ou manipuler des données réactives, à des fins ergonomiques ou cosmétiques.
</p><p>JavaScript n'est pas limité à la manipulation de documents HTML et peut aussi servir à manipuler des documents <a href="SVG" class="mw-redirect" title="SVG">SVG</a>, <a href="XUL" class="mw-redirect" title="XUL">XUL</a> et autres <a href="Extensible_Markup_Language" title="Extensible Markup Language">dialectes XML</a>.
</p>
<div class="mw-heading mw-heading4"><h4 id="Intégration"><span id="Int.C3.A9gration"></span>Intégration</h4></div>
<p>Il existe plusieurs façons d’intégrer JavaScript dans du code html:
</p>
<ul><li>Dans des attributs d’évènements html&nbsp;: <code>&lt;button onclick="alert('clic&nbsp;!')"&gt;clic ici&lt;/button&gt;</code>. Le code JavaScript <code>alert('clic&nbsp;!')</code>sera exécuté quand le bouton sera cliqué.</li>
<li>Dans des balises &lt;script&gt;&nbsp;: <code>&lt;script&gt;//ici on peut mettre du code JavaScript&lt;/script&gt;</code></li>
<li>Dans des fichiers externes&nbsp;: <code>&lt;script src="chemin/ver/mon/fichier.js"&gt;&lt;/script&gt;</code></li></ul>
<div class="mw-heading mw-heading4"><h4 id="Incompatibilité"><span id="Incompatibilit.C3.A9"></span>Incompatibilité</h4></div>
<p>Netscape et Microsoft (avec <a href="JScript" title="JScript">JScript</a> dans <a href="Internet_Explorer" title="Internet Explorer">Internet Explorer</a> jusqu'à la version 9) ont développé leur propre variante de ce langage qui chacune supporte presque intégralement la norme ECMAScript mais possède des fonctionnalités supplémentaires et incompatibles, rarement utilisées dans le cadre de la programmation de pages web. Pourtant les scripts JavaScript sont souvent la source de difficultés. Elles sont plus souvent dues à la prise en charge des différentes versions des modèles d'objets (<a href="Document_Object_Model" title="Document Object Model">DOM</a>) fournis par les navigateurs, qu'à des problèmes de <a href="Portabilit%C3%A9_(informatique)" title="Portabilité (informatique)">portabilité</a> du langage (les différentes mises en œuvre respectant relativement bien la norme ECMAScript).
</p><p>Pour vérifier dynamiquement si un objet (dans la version JavaScript utilisée lors de l'interprétation) possède bien une méthode, on utilise souvent une construction du type&nbsp;:
</p>
<div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">monObjet</span><span class="p">.</span><span class="nx">methode</span><span class="w"> </span><span class="o">&amp;&amp;</span><span class="w"> </span><span class="ow">typeof</span><span class="w"> </span><span class="nx">monObjet</span><span class="p">.</span><span class="nx">methode</span><span class="w"> </span><span class="o">===</span><span class="w"> </span><span class="s1">'function'</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="nx">monObjet</span><span class="p">.</span><span class="nx">methode</span><span class="p">();</span>
<span class="p">}</span>
</pre></div>
<p>On vérifie ainsi que <i>monObjet</i> a bien une mise en œuvre de <i>methode</i> que l'on peut alors utiliser. Le plus souvent, si un navigateur ne gère pas la <i>methode</i> de <i>monObjet</i>, il gère une méthode comparable <i>methode2</i>, et on peut alors adapter le code JavaScript au navigateur qui l'exécute&nbsp;:
</p>
<div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="ow">typeof</span><span class="w"> </span><span class="nx">monObjet</span><span class="p">.</span><span class="nx">methode</span><span class="w"> </span><span class="o">===</span><span class="w"> </span><span class="s1">'function'</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="nx">monObjet</span><span class="p">.</span><span class="nx">methode</span><span class="p">();</span>
<span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="ow">typeof</span><span class="w"> </span><span class="nx">monObjet</span><span class="p">.</span><span class="nx">methode2</span><span class="w"> </span><span class="o">===</span><span class="w"> </span><span class="s1">'function'</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="nx">monObjet</span><span class="p">.</span><span class="nx">methode2</span><span class="p">();</span>
<span class="p">}</span>
</pre></div>
<p>Une autre méthode consiste à vérifier, côté serveur, le navigateur utilisé par le client et d'envoyer le code correspondant. Cela n'est toutefois pas recommandable, car il est largement préférable de tester directement l'existence, le comportement d'une fonction, d'une propriété,&nbsp;<abbr class="abbr" title="et cetera">etc.</abbr> plutôt que de faire des présomptions basées sur la détection du navigateur.
</p>
<div class="mw-heading mw-heading4"><h4 id="Ajax">Ajax</h4></div>

<p><a href="Ajax_(informatique)" title="Ajax (informatique)">Ajax</a> (de l'anglais <i><span class="lang-en" lang="en">Asynchronous JavaScript And XML</span></i>) est un ensemble de techniques découplant l'échange de données entre le navigateur et le serveur web de l'affichage d'une page web, ce qui permet de modifier le contenu des pages web sans les recharger. Grâce à l'objet JavaScript <a href="XMLHttpRequest" title="XMLHttpRequest">XMLHTTPRequest</a>, cette méthode permet d'effectuer des requêtes HTTP sur le serveur web depuis le navigateur web, et permet également de traiter les réponses <a href="Hypertext_Transfer_Protocol" title="Hypertext Transfer Protocol">HTTP</a> du serveur web pour modifier le contenu de la page web. La réponse était en général au format <a href="Extensible_Markup_Language" title="Extensible Markup Language">XML</a> qui tend aujourd'hui à être remplacé par le format <a href="JavaScript_Object_Notation" title="JavaScript Object Notation">JSON</a> qui a l'avantage d'être natif en JavaScript. Le script manipule l'ensemble d'objets <a href="Document_Object_Model" title="Document Object Model">DOM</a> qui représente le contenu de la page web. Les technologies <a href="XMLHttpRequest" title="XMLHttpRequest">XMLHTTPRequest</a>, <a href="XML" class="mw-redirect" title="XML">XML</a> et <a href="Document_Object_Model" title="Document Object Model">DOM</a> ont été ajoutées aux navigateurs web entre 1995 et 2005. La méthode Ajax permet de réaliser des <a href="Web_2.0#Application_Internet_riche" title="Web 2.0">applications Internet riches</a>, offrant une maniabilité et un confort supérieur&nbsp;; c'est un des sujets phares du mouvement <a href="Web_2.0" title="Web 2.0">Web 2.0</a>.
</p>
<div class="mw-heading mw-heading4"><h4 id="JSON">JSON</h4></div>

<p><a href="JavaScript_Object_Notation" title="JavaScript Object Notation">JSON</a> (<i><span class="lang-en" lang="en">JavaScript Object Notation</span></i>) est un format utilisant la notation des objets JavaScript pour transmettre de l'information structurée, d'une façon plus compacte et plus proche des <a href="Langages_de_programmation" class="mw-redirect" title="Langages de programmation">langages de programmation</a>, que XML.
</p><p>Malgré l'existence du DOM et l'introduction récente de E4X (voir ci-dessous) dans la spécification du langage JavaScript, JSON reste le moyen le plus simple d'accéder à des données, puisque chaque flux JSON n'est rien d'autre qu'un objet JavaScript <a href="S%C3%A9rialisation" title="Sérialisation">sérialisé</a>. De plus, malgré son lien historique (et technique) avec JavaScript, JSON reste un <a href="Format_de_donn%C3%A9es" title="Format de données">format de données</a> structurées, et peut être utilisé facilement par tous les langages de programmation.
</p><p>Depuis 2009, les navigateurs commencent à intégrer un support natif du format JSON, ce qui facilite sa manipulation, la sécurité (contre l'évaluation de scripts malveillants inclus dans une chaine JSON), et la rapidité de traitement. Ainsi les navigateurs <a href="Mozilla_Firefox" title="Mozilla Firefox">Firefox</a> et <a href="Internet_Explorer" title="Internet Explorer">IE</a><sup id="cite_ref-27" class="reference"><a href="#cite_note-27"><span class="cite-bracket">[</span>27<span class="cite-bracket">]</span></a></sup> l'intègrent respectivement dès les versions 3.5 et 8.
</p><p>Exemple de JSON&nbsp;:
</p>
<div class="mw-highlight mw-highlight-lang-json mw-content-ltr mw-highlight-lines" dir="ltr"><pre><span></span><span class="linenos" data-line="1"></span><span class="p">{</span>
<span class="linenos" data-line="2"></span><span class="w"> </span><span class="nt">"clef1"</span><span class="p">:</span><span class="w"> </span><span class="s2">"valeur"</span><span class="p">,</span>
<span class="linenos" data-line="3"></span><span class="w"> </span><span class="nt">"clef2"</span><span class="p">:</span><span class="w"> </span><span class="mi">12345</span><span class="p">,</span>
<span class="linenos" data-line="4"></span><span class="w"> </span><span class="nt">"clef3"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span>
<span class="linenos" data-line="5"></span><span class="w"> </span><span class="nt">"clef4"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span>
<span class="linenos" data-line="6"></span><span class="w"> </span><span class="nt">"clef5"</span><span class="p">:</span><span class="w"> </span><span class="s2">"valeur"</span>
<span class="linenos" data-line="7"></span><span class="w"> </span><span class="p">}</span>
<span class="linenos" data-line="8"></span><span class="p">}</span>
</pre></div>
<p>La structure est organisée par clef/valeurs. Les clefs doivent être entre guillemets doubles. Les valeurs peuvent être&nbsp;:
</p>
<ul><li>une string (chaîne de caractères entre guillemets doubles)</li>
<li>un nombre</li>
<li>un booléen (true ou false pour vrai ou faux)</li>
<li>une structure clef/valeur</li></ul>
<p>Un JSON valide ne peut pas comporter de commentaires. Il existe des validateurs de JSON en ligne.
</p>
<div class="mw-heading mw-heading3"><h3 id="Autres_utilisations">Autres utilisations</h3></div>
<div class="mw-heading mw-heading4"><h4 id="Dans_la_barre_d’adresse_d’un_navigateur"><span id="Dans_la_barre_d.E2.80.99adresse_d.E2.80.99un_navigateur"></span>Dans la barre d’adresse d’un navigateur</h4></div>
<p>Taper des adresses comme <code>javascript: ducodejavascript</code> provoque l’exécution de ducodejavascript.
Exemple: javascript: alert(document.cookie) provoque l’affichage des cookies de la page.
</p>
<div class="mw-heading mw-heading4"><h4 id="Sur_un_serveur_web">Sur un serveur web</h4></div>
<p>JavaScript peut également être utilisé comme langage de programmation sur un <a href="Serveur_HTTP" class="mw-redirect" title="Serveur HTTP">serveur HTTP</a> à l'image des langages comme <a href="PHP" title="PHP">PHP</a>, <a href="Active_Server_Pages" title="Active Server Pages">ASP</a>, etc. D'ailleurs le projet <a href="CommonJS" title="CommonJS">CommonJS</a> travaille dans le but de spécifier un écosystème pour JavaScript en dehors du navigateur (par exemple sur le serveur ou pour les applications de bureau natives). Le projet a été lancé par Kevin Dangoor en <time class="nowrap" datetime="2009-01" data-sort-value="2009-01">janvier 2009</time>. Le projet CommonJS n'est pas affilié avec le groupe de l'Ecma International TC39 travaillant sur ECMAScript, mais certains membres du TC39 participent au projet.
</p><p>Historiquement, JavaScript était proposé sur les serveurs de <a href="Netscape_Communications_Corporation" class="mw-redirect" title="Netscape Communications Corporation">Netscape</a>, par la suite distribués par <a href="Sun_Microsystems" title="Sun Microsystems">Sun Microsystems</a> sous les noms <a href="IPlanet" title="IPlanet">iPlanet</a> et Sun ONE, mais <a href="JScript" title="JScript">JScript</a> peut aussi être utilisé sur les serveurs <a href="Internet_Information_Services" title="Internet Information Services">Internet Information Services</a> de <a href="Microsoft" title="Microsoft">Microsoft</a>. <a href="JScript" title="JScript">JScript</a> peut d'ailleurs servir pour scripter une plate-forme <a href="Microsoft_Windows" title="Microsoft Windows">Microsoft Windows</a> via <a href="Windows_Scripting_Host" title="Windows Scripting Host">Windows Scripting Host</a> (WSH).
</p><p>Il existe par ailleurs des projets indépendants et <a href="Open_source" title="Open source">Open Source</a> d'implémentation de serveurs en JavaScript. Parmi eux, on pourra distinguer <a href="Node.js" title="Node.js">Node.js</a>, une plateforme polyvalente de développement d'applications réseau se basant sur le moteur JavaScript V8 et les spécifications <a href="CommonJS" title="CommonJS">CommonJS</a>.
</p>
<div class="mw-heading mw-heading4"><h4 id="Autres_supports">Autres supports</h4></div>
<p><a href="ActionScript" title="ActionScript">ActionScript</a>, utilisé dans <a href="Adobe_Flash" title="Adobe Flash">Adobe Flash</a>, est aussi une mise en œuvre d'ECMAScript. Il permet de manipuler tous les éléments de l'animation, considérés comme des objets. JavaScript peut être utilisé pour scripter d'autres applications <a href="Adobe_Systems" class="mw-redirect" title="Adobe Systems">Adobe</a> (<a href="Adobe_Photoshop" title="Adobe Photoshop">Photoshop</a>, <a href="Adobe_Illustrator" title="Adobe Illustrator">Illustrator</a>, …), ce qui permet d'avoir des scripts indépendants de la plate-forme (Microsoft Windows, <a href="Apple" title="Apple">Apple</a> OSX, Linux…).
</p><p>JavaScript est enfin utilisé dans la plate-forme de développement de <a href="Mozilla_Foundation" title="Mozilla Foundation">Mozilla</a>, sur laquelle sont basés plusieurs logiciels comme des <a href="Navigateur_web" title="Navigateur web">navigateurs Web</a>, pour des tâches relatives à l'interface utilisateur et à la communication interne (ex.&nbsp;: les extensions de <a href="Mozilla_Firefox" title="Mozilla Firefox">Firefox</a> et <a href="Mozilla_Thunderbird" title="Mozilla Thunderbird">Thunderbird</a> sont installées à base de fichiers <a href="XPI" class="mw-redirect" title="XPI">XPI</a> utilisant le JavaScript. Voir aussi <a href="Prefs.js" class="mw-redirect" title="Prefs.js">Prefs.js</a>).
</p><p>Depuis 2004, l'objet <i>js</i> de l'environnement de programmation graphique <a href="Max/MSP" title="Max/MSP">Max/MSP</a> permet d'ouvrir une fenêtre pour programmer en JavaScript, au sein même d'un programme <a href="Max/MSP" title="Max/MSP">Max/MSP</a>.
</p><p>Les logiciels <a href="ImageJ" title="ImageJ">ImageJ</a> et <a href="CaRMetal" title="CaRMetal">CaRMetal</a> sont munis de consoles JavaScript, qui leur permettent d'écrire des scripts dans un contexte graphique. <a href="Algobox" title="Algobox">Algobox</a> utilise JavaScript pour la syntaxe de ses fonctions. <a href="H5P" title="H5P">H5P</a> se sert de <a href="HTML5" title="HTML5">HTML5</a> et Javascript pour faciliter la création de contenus interactifs en ligne.
</p><p>JavaScript est aussi utilisé dans un contenu <a href="Binary_Format_for_Scene" title="Binary Format for Scene">BIFS</a> pour l'exploitation des événements. Pour cela la spécification BIFS fournit un nœud Script pour incorporer de l'ECMAScript.
</p><p>La suite bureautique <a href="OpenOffice.org" title="OpenOffice.org">OpenOffice.org</a> permet d'utiliser JavaScript comme langage de macros.
</p><p>JavaScript est aussi utilisable en <a href="Shell_(informatique)" class="mw-redirect" title="Shell (informatique)">shell</a><sup id="cite_ref-28" class="reference"><a href="#cite_note-28"><span class="cite-bracket">[</span>28<span class="cite-bracket">]</span></a></sup> ou avec les gadgets Vista.
</p><p>Le format graphique vectoriel <a href="SVG" class="mw-redirect" title="SVG">SVG</a> incorpore le langage ECMAscript pour créer des graphiques interactifs directement exploitable dans un navigateur.
</p><p>Enfin, JavaScript est également utilisé pour dynamiser le QML de la bibliothèque graphique <a href="Qt" title="Qt">Qt</a>.
</p>
<div class="mw-heading mw-heading2"><h2 id="Particularités_du_langage"><span id="Particularit.C3.A9s_du_langage"></span>Particularités du langage</h2></div>
<div class="mw-heading mw-heading3"><h3 id="Liaison_des_identifiants">Liaison des identifiants</h3></div>
<p>En JavaScript, <i>toutes</i> les expressions (identifiants, littéraux et opérateurs et leurs opérandes) sont de <a href="R%C3%A9f%C3%A9rence_(programmation)" title="Référence (programmation)">type référence</a> (comme en <a href="Python_(langage)" title="Python (langage)">Python</a> et <a href="Ruby" title="Ruby">Ruby</a>, mais à la différence du <a href="C%2B%2B" title="C++">C++</a>, <a href="Java_(langage)" title="Java (langage)">Java</a>, <a href="C_sharp" class="mw-redirect" title="C sharp">C#</a>, <a href="Swift_(langage_d'Apple)" title="Swift (langage d'Apple)">Swift</a> et <a href="OCaml" title="OCaml">OCaml</a> qui possèdent aussi des expressions de type valeur), c'est-à-dire que leur évaluation ne produit pas une donnée directement mais une référence vers une donnée. La référence se nomme le <i>référent</i> de l’expression et la donnée le <i>référé</i> de l’expression.
</p><p>
En JavaScript, l'<a href="Affectation_(informatique)" title="Affectation (informatique)">affectation</a> d'une variable modifie son référent, autrement dit, elle lie la variable à une autre donnée&nbsp;: on parle de changement de liaison de la variable (en anglais <i>variable rebinding</i>).</p><div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="kd">var</span><span class="w"> </span><span class="nx">maVariable1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="c1">// lie `maVariable1` à une donnée de valeur 0</span>
<span class="kd">var</span><span class="w"> </span><span class="nx">maVariable2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">maVariable1</span><span class="p">;</span><span class="w"> </span><span class="c1">// lie `maVariable2` à la donnée liée à `maVariable1`</span>
<span class="nx">maVariable1</span><span class="o">++</span><span class="p">;</span><span class="w"> </span><span class="c1">// équivalent à `maVariable1 = maVariable1 + 1;`, relie `maVariable1` à une nouvelle donnée de valeur maVariable1 + 1 (affectation) juin</span>
<span class="nx">alert</span><span class="p">(</span><span class="nx">maVariable1</span><span class="p">);</span><span class="w"> </span><span class="c1">// affiche 1</span>
<span class="nx">alert</span><span class="p">(</span><span class="nx">maVariable2</span><span class="p">);</span><span class="w"> </span><span class="c1">// affiche 0</span>

<span class="kd">var</span><span class="w"> </span><span class="nx">maVariable3</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="mf">1</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="p">,</span><span class="w"> </span><span class="mf">3</span><span class="p">];</span><span class="w"> </span><span class="c1">// lie `maVariable3` à une donnée de valeur [1, 2, 3]</span>
<span class="kd">var</span><span class="w"> </span><span class="nx">maVariable4</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">maVariable3</span><span class="p">;</span><span class="w"> </span><span class="c1">// lie `maVariable4` à la donnée liée à `maVariable3`</span>
<span class="nx">maVariable3</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="mf">4</span><span class="p">,</span><span class="w"> </span><span class="mf">5</span><span class="p">,</span><span class="w"> </span><span class="mf">6</span><span class="p">];</span><span class="w"> </span><span class="c1">// relie `maVariable3` à une nouvelle donnée de valeur [4, 5, 6] (affectation)</span>
<span class="nx">alert</span><span class="p">(</span><span class="nx">maVariable3</span><span class="p">);</span><span class="w"> </span><span class="c1">// affiche [4, 5, 6]</span>
<span class="nx">alert</span><span class="p">(</span><span class="nx">maVariable4</span><span class="p">);</span><span class="w"> </span><span class="c1">// affiche [1, 2, 3]</span>

<span class="kd">var</span><span class="w"> </span><span class="nx">maVariable5</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="mf">1</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="p">,</span><span class="w"> </span><span class="mf">3</span><span class="p">];</span><span class="w"> </span><span class="c1">// lie `maVariable5` à une donnée de valeur [1, 2, 3]</span>
<span class="kd">var</span><span class="w"> </span><span class="nx">maVariable6</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">maVariable5</span><span class="p">;</span><span class="w"> </span><span class="c1">// lie `maVariable6` à la donnée liée à `maVariable5`</span>
<span class="nx">maVariable5</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="mf">4</span><span class="p">);</span><span class="w"> </span><span class="c1">// modifie la donnée liée à `maVariable5` et `maVariable6`</span>
<span class="nx">alert</span><span class="p">(</span><span class="nx">maVariable5</span><span class="p">);</span><span class="w"> </span><span class="c1">// affiche [1, 2, 3, 4]</span>
<span class="nx">alert</span><span class="p">(</span><span class="nx">maVariable6</span><span class="p">);</span><span class="w"> </span><span class="c1">// affiche [1, 2, 3, 4]</span>
</pre></div>
<div class="mw-heading mw-heading3"><h3 id="Portée_lexicale_des_variables"><span id="Port.C3.A9e_lexicale_des_variables"></span>Portée lexicale des variables</h3></div>
<p>La <i><a href="Port%C3%A9e_lexicale" title="Portée lexicale">portée lexicale</a></i> d'une variable est la partie d'un programme où la liaison entre son identifiant et sa donnée est valide. En JavaScript, la portée lexicale d'une variable peut être de deux types, selon le mot-clé utilisé pour la déclarer&nbsp;:
</p>
<ul><li><code>var</code>&nbsp;: au niveau de la <i>fonction</i> (ou de l'espace global) où elle est déclarée (comme en <a href="Python_(langage)" title="Python (langage)">Python</a>, <a href="Ruby" title="Ruby">Ruby</a>)&nbsp;;</li>
<li><code>let</code> ou <code>const</code> (introduits dans ECMAScript 6)&nbsp;: au niveau du <i>bloc</i> où elle est déclarée (comme en <a href="C%2B%2B" title="C++">C++</a>, <a href="Java_(langage)" title="Java (langage)">Java</a>, <a href="C_sharp" class="mw-redirect" title="C sharp">C#</a>) — une fonction étant un bloc particulier.</li></ul><p>
Depuis le support de <code>let</code> par les navigateurs modernes, <code>var</code> ne doit plus être utilisé et son utilisation est considéré comme une mauvaise pratique<sup id="cite_ref-29" class="reference"><a href="#cite_note-29"><span class="cite-bracket">[</span>29<span class="cite-bracket">]</span></a></sup>.</p><div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="c1">// 1. Déclaration dans un bloc</span>

<span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="kc">true</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// début du bloc</span>
<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">maVariable1</span><span class="p">;</span><span class="w"> </span><span class="c1">// déclaration de la variable</span>
<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">maVariable2</span><span class="p">;</span><span class="w"> </span><span class="c1">// déclaration de la variable</span>
<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">maVariable3</span><span class="p">;</span><span class="w"> </span><span class="c1">// déclaration de la variable</span>
<span class="p">}</span><span class="w"> </span><span class="c1">// fin du bloc mais pas de la portée de maVariable1</span>

<span class="nx">alert</span><span class="p">(</span><span class="nx">maVariable1</span><span class="p">);</span><span class="w"> </span><span class="c1">// ne soulève pas d'erreur</span>
<span class="nx">alert</span><span class="p">(</span><span class="nx">maVariable2</span><span class="p">);</span><span class="w"> </span><span class="c1">// erreur&nbsp;: la variable est hors de sa portée</span>
<span class="nx">alert</span><span class="p">(</span><span class="nx">maVariable3</span><span class="p">);</span><span class="w"> </span><span class="c1">// erreur&nbsp;: la variable est hors de sa portée</span>

<span class="c1">// 2. Déclaration dans une fonction</span>

<span class="kd">function</span><span class="w"> </span><span class="nx">maFunction</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// début de la fonction</span>
<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">maVariable4</span><span class="p">;</span><span class="w"> </span><span class="c1">// déclaration de la variable</span>
<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">maVariable5</span><span class="p">;</span><span class="w"> </span><span class="c1">// déclaration de la variable</span>
<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">maVariable6</span><span class="p">;</span><span class="w"> </span><span class="c1">// déclaration de la variable</span>
<span class="p">}</span><span class="w"> </span><span class="c1">// fin de la fonction et de la portée des variables</span>

<span class="nx">alert</span><span class="p">(</span><span class="nx">maVariable4</span><span class="p">);</span><span class="w"> </span><span class="c1">// erreur&nbsp;: la variable est hors de sa portée</span>
<span class="nx">alert</span><span class="p">(</span><span class="nx">maVariable5</span><span class="p">);</span><span class="w"> </span><span class="c1">// erreur&nbsp;: la variable est hors de sa portée</span>
<span class="nx">alert</span><span class="p">(</span><span class="nx">maVariable6</span><span class="p">);</span><span class="w"> </span><span class="c1">// erreur&nbsp;: la variable est hors de sa portée</span>
</pre></div>
<p>Une variable peut être affectée ou masquée par une fonction enfant de la fonction (ou de l'espace global) où elle est déclarée&nbsp;:
</p>
<div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="kd">var</span><span class="w"> </span><span class="nx">maVariable1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="c1">// définition de la variable parente</span>

<span class="c1">// 1. Affectation</span>

<span class="kd">function</span><span class="w"> </span><span class="nx">maFonction1</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// fonction enfant</span>
<span class="w"> </span><span class="nx">maVariable1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">1</span><span class="p">;</span><span class="w"> </span><span class="c1">// affectation de la variable parente</span>
<span class="p">}</span>

<span class="nx">alert</span><span class="p">(</span><span class="nx">maVariable1</span><span class="p">);</span><span class="w"> </span><span class="c1">// affiche 0</span>
<span class="nx">maFonction1</span><span class="p">();</span><span class="w"> </span><span class="c1">// affecte la variable parente</span>
<span class="nx">alert</span><span class="p">(</span><span class="nx">maVariable1</span><span class="p">);</span><span class="w"> </span><span class="c1">// affiche 1</span>

<span class="c1">// 2. Masquage</span>

<span class="kd">var</span><span class="w"> </span><span class="nx">maVariable2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="c1">// définition de la variable parente</span>

<span class="kd">function</span><span class="w"> </span><span class="nx">maFonction2</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// fonction enfant</span>
<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">maVariable2</span><span class="p">;</span><span class="w"> </span><span class="c1">// déclaration de la variable enfant masquant la variable parente</span>
<span class="w"> </span><span class="nx">maVariable2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">1</span><span class="p">;</span><span class="w"> </span><span class="c1">// affectation de la variable enfant</span>
<span class="p">}</span>

<span class="nx">alert</span><span class="p">(</span><span class="nx">maVariable2</span><span class="p">);</span><span class="w"> </span><span class="c1">// affiche 0</span>
<span class="nx">maFonction2</span><span class="p">();</span>
<span class="nx">alert</span><span class="p">(</span><span class="nx">maVariable2</span><span class="p">);</span><span class="w"> </span><span class="c1">// affiche 0</span>
</pre></div>
<div class="mw-heading mw-heading3"><h3 id="Déclaration_des_variables"><span id="D.C3.A9claration_des_variables"></span>Déclaration des variables</h3></div>
<p>En JavaScript, quel que soit le lieu de la déclaration d'une variable dans sa portée lexicale, la variable est <i>créée</i> au début de l'évaluation de sa portée lexicale.
</p><p>
Les variables déclarées avec le mot-clé <code>var</code> sont en plus <i>pré-initialisées</i> à la valeur <code>undefined</code> lors de leur création, et donc accessibles dès le début de leur portée lexicale. On parle de <i>remontée de la variable</i> (<i>variable hoisting</i> en anglais) car cela se passe comme si la déclaration de la variable était remontée au début de sa portée lexicale&nbsp;:</p><div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="nx">alert</span><span class="p">(</span><span class="nx">maVariable</span><span class="p">);</span><span class="w"> </span><span class="c1">// affiche undefined</span>
<span class="kd">var</span><span class="w"> </span><span class="nx">maVariable</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span>
<span class="nx">alert</span><span class="p">(</span><span class="nx">maVariable</span><span class="p">);</span><span class="w"> </span><span class="c1">// affiche 0</span>
</pre></div><p>Les variables déclarées avec le mot-clé <code>let</code> ou <code>const</code> (ECMAScript 6) ne sont pas pré-initialisées, et donc inaccessibles avant leur déclaration. Si une variable déclarée avec le mot-clé <code>let</code> ne possède pas d'initialiseur, elle est initialisée à la valeur <code>undefined</code> lors de l'évaluation de la déclaration, sinon elle est initialisée avec l'initialiseur lors de l'évaluation de la déclaration. Si une variable déclarée avec le mot-clé <code>const</code> ne possède pas d'initialiseur, une erreur est levée lors de l'évaluation de la déclaration, sinon elle est initialisée avec l'initialiseur lors de l'évaluation de la déclaration&nbsp;:
</p><div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="c1">// 1. Avec initialiseur</span>

<span class="nx">alert</span><span class="p">(</span><span class="nx">maVariable1</span><span class="p">);</span><span class="w"> </span><span class="c1">// erreur&nbsp;: accès impossible avant l'initialisation</span>
<span class="nx">alert</span><span class="p">(</span><span class="nx">maVariable2</span><span class="p">);</span><span class="w"> </span><span class="c1">// erreur&nbsp;: accès impossible avant l'initialisation</span>
<span class="kd">let</span><span class="w"> </span><span class="nx">maVariable1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">5</span><span class="p">;</span>
<span class="kd">const</span><span class="w"> </span><span class="nx">maVariable2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">8</span><span class="p">;</span>
<span class="nx">alert</span><span class="p">(</span><span class="nx">maVariable1</span><span class="p">);</span><span class="w"> </span><span class="c1">// affiche 5</span>
<span class="nx">alert</span><span class="p">(</span><span class="nx">maVariable2</span><span class="p">);</span><span class="w"> </span><span class="c1">// affiche 8</span>

<span class="c1">// 2. Sans initialiseur</span>

<span class="nx">alert</span><span class="p">(</span><span class="nx">maVariable3</span><span class="p">);</span><span class="w"> </span><span class="c1">// erreur&nbsp;: accès impossible avant l'initialisation</span>
<span class="nx">alert</span><span class="p">(</span><span class="nx">maVariable4</span><span class="p">);</span><span class="w"> </span><span class="c1">// erreur&nbsp;: accès impossible avant l'initialisation</span>
<span class="kd">let</span><span class="w"> </span><span class="nx">maVariable3</span><span class="p">;</span>
<span class="kd">const</span><span class="w"> </span><span class="nx">maVariable4</span><span class="p">;</span><span class="w"> </span><span class="c1">// erreur&nbsp;: initialisation manquante</span>
<span class="nx">alert</span><span class="p">(</span><span class="nx">maVariable3</span><span class="p">);</span><span class="w"> </span><span class="c1">// affiche undefined</span>
<span class="nx">alert</span><span class="p">(</span><span class="nx">maVariable4</span><span class="p">);</span><span class="w"> </span><span class="c1">// erreur&nbsp;: initialisation manquante</span>
</pre></div><p>
De plus, JavaScript autorise la redéclaration de la même variable dans sa portée lexicale, mais uniquement avec le mot-clé <code>var</code>&nbsp;:</p><div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="kd">var</span><span class="w"> </span><span class="nx">maVariable</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">2</span><span class="p">;</span>
<span class="kd">var</span><span class="w"> </span><span class="nx">maVariable</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">9</span><span class="p">;</span>
</pre></div>
<div class="mw-heading mw-heading3"><h3 id="Variables_globales">Variables globales</h3></div>
<p>En JavaScript, il existe plusieurs façons de déclarer une <i>variable globale</i>, et certaines interagissent avec l'<i>objet global</i> (nommé <code>window</code> dans les navigateurs)&nbsp;:
</p>
<div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="kd">var</span><span class="w"> </span><span class="nx">maVariable1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="c1">// propriété ou méthode de l'objet global qui ne peut pas être détruite par l'opérateur delete</span>
<span class="kd">let</span><span class="w"> </span><span class="nx">maVariable2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="c1">// pas une propriété ou méthode de l'objet global</span>
<span class="kd">const</span><span class="w"> </span><span class="nx">maVariable3</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="c1">// pas une propriété ou méthode de l'objet global</span>
<span class="nx">maVariable4</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="c1">// propriété ou méthode de l'objet global qui peut être détruite par l'opérateur delete</span>
<span class="nb">window</span><span class="p">.</span><span class="nx">maVariable5</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="c1">// propriété ou méthode de l'objet global qui peut être détruite par l'opérateur delete</span>
<span class="k">this</span><span class="p">.</span><span class="nx">maVariable6</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="c1">// propriété ou méthode de l'objet global qui peut être détruite par l'opérateur delete</span>
</pre></div>
<p>Une variable initialisée sans déclaration est traitée comme une <a href="Variable_globale" title="Variable globale">variable globale</a>&nbsp;:
</p>
<div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="kd">function</span><span class="w"> </span><span class="nx">maFonction</span><span class="p">()</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="nx">maVariable</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">5</span><span class="p">;</span>
<span class="p">}</span>

<span class="nx">maFonction</span><span class="p">();</span>
<span class="nx">alert</span><span class="p">(</span><span class="nx">maVariable</span><span class="p">);</span><span class="w"> </span><span class="c1">// affiche 5</span>
</pre></div>
<div class="mw-heading mw-heading3"><h3 id="Fonctions_anonymes">Fonctions anonymes</h3></div>
<p>Les <i><a href="Fonction_anonyme" title="Fonction anonyme">fonctions anonymes</a></i> sont, comme leur nom l'indique, des fonctions qui ne portent pas de nom&nbsp;:
</p>
<div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="nx">setTimeout</span><span class="p">(</span><span class="kd">function</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="nx">alert</span><span class="p">(</span><span class="s1">'Trois secondes se sont écoulées.'</span><span class="p">);</span>
<span class="p">},</span><span class="w"> </span><span class="mf">3000</span><span class="p">);</span>
</pre></div>
<p>Celle-ci est donnée en paramètre à la fonction <code>setTimeout</code>, qui permet de définir une durée avant d'afficher le message.
</p>
<div class="mw-heading mw-heading3"><h3 id="Fermetures_lexicales">Fermetures lexicales</h3></div>
<p>Un <i>environnement lexical</i> est l'ensemble des variables valides dans une partie du programme. Il est composé de l'environnement lexical <i>interne</i> (les <a href="Variable_locale" title="Variable locale">variables locales</a>) et d'une référence à l'environnement lexical <i>externe</i> (les variables non locales).
</p><p>Une <a href="Fermeture_(informatique)" title="Fermeture (informatique)"><i>fermeture lexicale</i></a> (<i>lexical closure</i> en anglais) est une fonction accompagnée de son environnement lexical externe, c'est-à-dire de l'ensemble des variables non locales qu'elle a capturé, soit par <i>valeur</i> (conservation d'une copie de chaque donnée liée aux variables non locales), soit par <i>référence</i> (conservation d'une référence à chaque donnée liée aux variables non locales). Comme en JavaScript toutes les variables sont de type référence (cf. la section <a href="#Liaison_des_identifiants">Liaison des identifiants</a>), JavaScript n'utilise que la capture par référence — ce qui correspond en <a href="C%2B%2B11" title="C++11">C++ 11</a> à la syntaxe <code>[&amp;](…) { … };</code> —, et la durée de vie des variables non locales capturées par une fonction est étendue à la durée de vie de la fonction — ce qui n'est pas le cas en C++ 11, quel que soit le type de capture&nbsp;:
</p>
<div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="kd">function</span><span class="w"> </span><span class="nx">maFonction</span><span class="p">()</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">maVariable</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">4</span><span class="p">;</span><span class="w"> </span><span class="c1">// variable parente</span>

<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="nx">alert</span><span class="p">(</span><span class="nx">maVariable</span><span class="p">);</span>
<span class="w"> </span><span class="p">}</span>
<span class="p">}</span>

<span class="kd">var</span><span class="w"> </span><span class="nx">maFermeture</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">maFonction</span><span class="p">();</span><span class="w"> </span><span class="c1">// capture de la variable parente par référence</span>
<span class="nx">maFermeture</span><span class="p">();</span><span class="w"> </span><span class="c1">// affiche 4</span>
</pre></div>
<div class="mw-heading mw-heading3"><h3 id="Expressions_de_fonctions_immédiatement_invoquées"><span id="Expressions_de_fonctions_imm.C3.A9diatement_invoqu.C3.A9es"></span>Expressions de fonctions immédiatement invoquées</h3></div>
<p>Jusqu'à ECMAScript 6, JavaScript ne proposait pas nativement de portée des variables au niveau des blocs (pas de mots-clé <code>let</code> ou <code>const</code>), ni de <a href="Module_(programmation)" title="Module (programmation)">modules</a>. Pour éviter de polluer l'espace global, une méthode consistait à encapsuler son code dans une fonction pour s'appuyer sur la portée des variables qui a lieu au niveau des fonctions en JavaScript, puis à invoquer cette fonction juste après. Pour regrouper les deux étapes (définition de la fonction et invocation) et ne pas ajouter un nom de fonction supplémentaire dans l'espace global, le langage permet les <i>expressions de fonctions immédiatement invoquées</i> (EFII&nbsp;; en anglais <i>immediately-invoked function expressions</i>, IIFE)<sup id="cite_ref-30" class="reference"><a href="#cite_note-30"><span class="cite-bracket">[</span>30<span class="cite-bracket">]</span></a></sup>.
</p><p>Plusieurs syntaxes sont possibles pour ce type d'expression, les plus répandues étant&nbsp;:
</p>
<ul><li><code><b>(</b>function (…) { … }(…)<b>)</b>;</code> (syntaxe recommandée par <a href="Douglas_Crockford" title="Douglas Crockford">Douglas Crockford</a> pour sa lisibilité)<sup id="cite_ref-31" class="reference"><a href="#cite_note-31"><span class="cite-bracket">[</span>31<span class="cite-bracket">]</span></a></sup>&nbsp;;</li>
<li><code><b>(</b>function (…) { … }<b>)</b>(…);</code></li></ul>
<p>L'opérateur d'invocation de fonction <code>()</code> à la fin permet l'exécution immédiate de la fonction. Les parenthèses en gras indiquent à l'analyseur syntaxique qu'elles contiennent une expression, car en JavaScript les parenthèses ne peuvent pas contenir de déclaration. Autrement, dans la plupart des situations, le mot clé <code>function</code> est traité comme une déclaration de fonction, et pas comme une expression de fonction. Il existe d'autres façons pour forcer une expression de fonction&nbsp;:
</p>
<ul><li><code>!function (…) { … }(…);</code></li>
<li><code>~function (…) { … }(…);</code></li>
<li><code>-function (…) { … }(…);</code></li>
<li><code>+function (…) { … }(…);</code></li></ul>
<p>Dans les contextes où une expression est attendue il n'est pas nécessaire d'utiliser les parenthèses en gras&nbsp;:
</p>
<ul><li><code>var maVariable = function (…) { … }(…);</code></li>
<li><code>true &amp;&amp; function (…) { … }(…);</code></li>
<li><code>0, function (…) { … }(…);</code></li></ul>
<p>Une utilisation importante des expressions de fonctions immédiatement invoquées est pour la création de modules. Les modules permettent à la fois de rassembler des propriétés et des méthodes dans un espace de nom et de rendre certains membres privés&nbsp;:
</p>
<div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="kd">var</span><span class="w"> </span><span class="nx">compteur</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="kd">function</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="c1">// propriété privée</span>

<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// méthodes publiques</span>
<span class="w"> </span><span class="nx">obtenir</span><span class="o">:</span><span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="nx">alert</span><span class="p">(</span><span class="nx">i</span><span class="p">);</span>
<span class="w"> </span><span class="p">},</span>
<span class="w"> </span><span class="nx">mettre</span><span class="o">:</span><span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="p">(</span><span class="nx">valeur</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">valeur</span><span class="p">;</span>
<span class="w"> </span><span class="p">},</span>
<span class="w"> </span><span class="nx">incrementer</span><span class="o">:</span><span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="nx">alert</span><span class="p">(</span><span class="o">++</span><span class="nx">i</span><span class="p">);</span>
<span class="w"> </span><span class="p">}</span>
<span class="w"> </span><span class="p">};</span>
<span class="p">})();</span><span class="w"> </span><span class="c1">// module</span>

<span class="nx">compteur</span><span class="p">.</span><span class="nx">obtenir</span><span class="p">();</span><span class="w"> </span><span class="c1">// affiche 0</span>
<span class="nx">compteur</span><span class="p">.</span><span class="nx">mettre</span><span class="p">(</span><span class="mf">6</span><span class="p">);</span>
<span class="nx">compteur</span><span class="p">.</span><span class="nx">incrementer</span><span class="p">();</span><span class="w"> </span><span class="c1">// affiche 7</span>
<span class="nx">compteur</span><span class="p">.</span><span class="nx">incrementer</span><span class="p">();</span><span class="w"> </span><span class="c1">// affiche 8</span>
<span class="nx">compteur</span><span class="p">.</span><span class="nx">incrementer</span><span class="p">();</span><span class="w"> </span><span class="c1">// affiche 9</span>
</pre></div>
<div class="mw-heading mw-heading3"><h3 id="Prototypes">Prototypes</h3></div>
<p>Les <a href="Programmation_orient%C3%A9e_prototype" title="Programmation orientée prototype"><i>prototypes</i></a> sont des objets utilisés lors d'un échec de résolution de nom. Ce mécanisme est un type d'héritage&nbsp;: l'héritage par prototype. En JavaScript, tout objet possède un prototype, accessible via la méthode <code>Object.getPrototypeOf</code> (ou via la propriété historique <code>__proto__</code> standardisée dans ECMAScript 6 pour assurer la compatibilité entre les navigateurs mais non recommandée). De plus, l'opérateur <code>new</code> permet de transformer l'invocation d'une fonction constructeur en un objet (instanciation) dont le prototype est égal à la propriété <code>prototype</code> de la fonction constructeur&nbsp;:
</p>
<div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="kd">function</span><span class="w"> </span><span class="nx">MonConstructeur</span><span class="p">()</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">this</span><span class="p">.</span><span class="nx">maPropriete1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">3</span><span class="p">;</span>
<span class="p">}</span>

<span class="kd">const</span><span class="w"> </span><span class="nx">monInstance</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="nx">MonConstructeur</span><span class="p">();</span>
<span class="nx">alert</span><span class="p">(</span><span class="nx">monInstance</span><span class="p">.</span><span class="nx">maPropriete1</span><span class="p">);</span><span class="w"> </span><span class="c1">// affiche 3</span>
<span class="nx">alert</span><span class="p">(</span><span class="nb">Object</span><span class="p">.</span><span class="nx">getPrototypeOf</span><span class="p">(</span><span class="nx">monInstance</span><span class="p">)</span><span class="w"> </span><span class="o">===</span><span class="w"> </span><span class="nx">MonConstructeur</span><span class="p">.</span><span class="nx">prototype</span><span class="p">);</span><span class="w"> </span><span class="c1">// affiche true</span>
<span class="nx">MonConstructeur</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">maPropriete2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">5</span><span class="p">;</span>
<span class="nx">alert</span><span class="p">(</span><span class="nx">monInstance</span><span class="p">.</span><span class="nx">maPropriete2</span><span class="p">);</span><span class="w"> </span><span class="c1">// affiche 5</span>
</pre></div>
<p>Toute instance de <code>MonConstructeur</code> (<code>monInstance</code> ici) possède un prototype égal à <code>MonConstructeur.prototype</code>. Lors de l'utilisation d'une propriété ou d'une méthode d'une instance de <code>MonConstructeur</code> (<code>monInstance.maPropriete1</code> et <code>monInstance.maPropriete2</code> ici), si l'instance ne possède pas la propriété ou la méthode recherchée, la recherche se poursuit dans le prototype de l'instance (<code>MonConstructeur.prototype</code> ici). Si la recherche échoue aussi avec cet objet, la recherche se poursuit dans le prototype de cet objet, et ainsi de suite jusqu'à arriver à la première fonction constructeur. Si la recherche échoue encore, cette première fonction constructeur étant une fonction donc une instance de la fonction constructeur <code>Function</code> du langage, la recherche se poursuit dans son prototype qui est égal à <code>Function.prototype</code>. Si la recherche échoue à nouveau, <code>Function.prototype</code> étant un objet donc une instance de la fonction constructeur <code>Object</code> du langage, la recherche se poursuit dans son prototype qui est égal à <code>Object.prototype</code>. Si la recherche échoue cette fois, comme le prototype de <code>Object.prototype</code> est égal à <code>null</code>, la recherche s'arrête et JavaScript génère une erreur de résolution de nom. Ce mécanisme de recherche parcourt ce qu'on appelle la <i>chaîne de prototypes</i>.
</p><p>Le code de l'opérateur <code>instanceOf</code> illustre bien ce mécanisme. <code>A instanceOf B</code> (ou de manière équivalente&nbsp;: <code>instanceOf.call(A, B)</code>) renvoie <code>true</code> si <code>A</code> est une instance de <code>B</code>, c'est-à-dire si <code>B.prototype</code> est trouvé dans le chaîne de prototypes de <code>A</code>, et <code>false</code> sinon&nbsp;:
</p>
<div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="kd">function</span><span class="w"> </span><span class="nx">instanceOf</span><span class="p">(</span><span class="nx">f</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">o</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">this</span><span class="p">;</span>

<span class="w"> </span><span class="k">while</span><span class="w"> </span><span class="p">(</span><span class="nx">o</span><span class="w"> </span><span class="o">!==</span><span class="w"> </span><span class="kc">null</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="nx">o</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Object</span><span class="p">.</span><span class="nx">getPrototypeOf</span><span class="p">(</span><span class="nx">o</span><span class="p">);</span>

<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">o</span><span class="w"> </span><span class="o">===</span><span class="w"> </span><span class="nx">f</span><span class="p">.</span><span class="nx">prototype</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="kc">true</span><span class="p">;</span>
<span class="w"> </span><span class="p">}</span>
<span class="w"> </span><span class="p">}</span>

<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="kc">false</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
<p>Par ailleurs, la méthode <code>Object.create</code> introduite dans ECMAScript 5 permet d'éviter d'utiliser directement les fonctions constructeurs, leurs propriétés <code>prototype</code> et l'opérateur <code>new</code>, pour ne travailler qu'avec des objets. L'utilisation de cette méthode simplifie grandement la complexité du code et est donc recommandée. La méthode <code>Object.create</code> est définie par
</p>
<div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="ow">typeof</span><span class="w"> </span><span class="nb">Object</span><span class="p">.</span><span class="nx">create</span><span class="w"> </span><span class="o">!==</span><span class="w"> </span><span class="s1">'function'</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="nb">Object</span><span class="p">.</span><span class="nx">create</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="p">(</span><span class="nx">o</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="nx">F</span><span class="p">()</span><span class="w"> </span><span class="p">{}</span>
<span class="w"> </span><span class="nx">F</span><span class="p">.</span><span class="nx">prototype</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">o</span><span class="p">;</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="nx">F</span><span class="p">();</span>
<span class="w"> </span><span class="p">};</span>
<span class="p">}</span>
</pre></div>
<p>L'exemple précédent peut alors être réécrit
</p>
<div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="kd">const</span><span class="w"> </span><span class="nx">MonObjet</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="nx">initialiser</span><span class="p">()</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">this</span><span class="p">.</span><span class="nx">maPropriete1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">3</span><span class="p">;</span>
<span class="w"> </span><span class="p">}</span>
<span class="p">}</span>

<span class="kd">const</span><span class="w"> </span><span class="nx">monInstance</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Object</span><span class="p">.</span><span class="nx">create</span><span class="p">(</span><span class="nx">MonObjet</span><span class="p">);</span>
<span class="nx">monInstance</span><span class="p">.</span><span class="nx">initialiser</span><span class="p">();</span>
<span class="nx">alert</span><span class="p">(</span><span class="nx">monInstance</span><span class="p">.</span><span class="nx">maPropriete1</span><span class="p">);</span><span class="w"> </span><span class="c1">// affiche 3</span>
<span class="nx">MonObjet</span><span class="p">.</span><span class="nx">maPropriete2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">5</span><span class="p">;</span>
<span class="nx">alert</span><span class="p">(</span><span class="nx">monInstance</span><span class="p">.</span><span class="nx">maPropriete2</span><span class="p">);</span><span class="w"> </span><span class="c1">// affiche 5</span>
</pre></div>
<div class="mw-heading mw-heading3"><h3 id="Séparation_des_instructions"><span id="S.C3.A9paration_des_instructions"></span>Séparation des instructions</h3></div>
<p>En <a href="C_(langage)" title="C (langage)">C</a>, chaque instruction se termine par un <a href="Point-virgule" title="Point-virgule">point-virgule</a>. Cette pratique a fait du point-virgule une obligation dans de nombreux langages inspirés de la syntaxe du C.
</p><p>
JavaScript est plus souple, permettant à une <a href="Fin_de_ligne" title="Fin de ligne">fin de ligne</a> de marquer implicitement la fin d'une instruction. Le but est de faciliter l'usage du langage aux personnes inexpérimentées en <a href="Programmation_informatique" title="Programmation informatique">programmation informatique</a>. Mais cette souplesse introduit des effets inattendus<sup id="cite_ref-32" class="reference"><a href="#cite_note-32"><span class="cite-bracket">[</span>32<span class="cite-bracket">]</span></a></sup>&nbsp;:</p><div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="k">return</span>
<span class="w"> </span><span class="kc">true</span><span class="p">;</span>
</pre></div><p>Le parseur comprend cela comme deux instructions&nbsp;: </p><div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="k">return</span><span class="p">;</span>
<span class="kc">true</span><span class="p">;</span>
</pre></div><p>Les expressions de fonctions immédiatement invoquées lorsque le programmeur s'appuie sur les fins d'instruction implicites rencontrent également ce genre de problème avec l'usage des parenthèses&nbsp;:
</p><div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="nx">maVariable1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">maVariable2</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">maVariable3</span>

<span class="p">(</span><span class="kd">function</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="c1">// code</span>
<span class="p">})()</span>
</pre></div><p>est traité comme</p><div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="nx">maVariable1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">maVariable2</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">maVariable3</span><span class="p">(</span><span class="kd">function</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="cm">/* code */</span><span class="w"> </span><span class="p">})();</span>
</pre></div><p>Les ouvrages de programmation avancés en JavaScript mettent en garde contre les effets inattendus de la déduction automatique de fin d'instruction et conseillent d'écrire un point-virgule à la fin de chaque instruction, ce qui n'empêche pas les surprises lorsqu'on oublie le point-virgule, d'autant plus quand la compression du code impose le retrait des retours chariot.
</p><div class="mw-heading mw-heading2"><h2 id="Annexes">Annexes</h2></div>
<style data-mw-deduplicate="TemplateStyles:r194021218">
/* start https://fr.wikipedia.org/ */


.mw-parser-output .autres-projets>.titre{text-align:center;margin:0.2em 0}.mw-parser-output .autres-projets>ul{margin:0;padding:0}.mw-parser-output .autres-projets>ul>li{list-style:none;margin:0.2em 0;text-indent:0;padding-left:24px;min-height:20px;text-align:left;display:block}.mw-parser-output .autres-projets>ul>li>a{font-style:italic}@media(max-width:720px){.mw-parser-output .autres-projets{float:none}}


/* end https://fr.wikipedia.org/ */
</style>
<div class="mw-heading mw-heading3"><h3 id="Articles_connexes">Articles connexes</h3></div>
<ul><li><a href="Syntaxe_JavaScript" title="Syntaxe JavaScript">Syntaxe JavaScript</a></li>
<li><a href="Moteur_JavaScript" title="Moteur JavaScript">Moteur JavaScript</a></li>
<li><a href="Sp%C3%A9cification_de_JavaScript" title="Spécification de JavaScript">Spécification de JavaScript</a></li>
<li>Sécurité du navigateur&nbsp;<a href="https://en.wikipedia.org/wiki/Browser_security" class="extiw external" title="en:Browser security"><span class="indicateur-langue" title="Article en anglais&nbsp;: «&nbsp;Browser security&nbsp;»">(en)</span></a></li>
<li><a href="JQuery" title="JQuery">jQuery</a></li>
<li><a href="DataTables" title="DataTables">DataTables</a></li>
<li><a href="TypeScript" title="TypeScript">TypeScript</a></li></ul>
<div class="mw-heading mw-heading3"><h3 id="Liens_externes">Liens externes</h3></div>
<ul><li><abbr class="abbr indicateur-langue" title="Langue : anglais">(en)</abbr> <a rel="nofollow" class="external text" href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">Standard ECMA-262, <i>ECMAScript 2016 Language Specification</i></a></li>
<li><a rel="nofollow" class="external text" href="https://developer.mozilla.org/fr/JavaScript">Mozilla Developer Center - JavaScript</a></li>
<li><abbr class="abbr indicateur-langue" title="Langue : anglais">(en)</abbr> <a rel="nofollow" class="external text" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/js56jsoriJScript.asp">Microsoft MSDN - JScript</a></li>
<li><abbr class="abbr indicateur-langue" title="Langue : anglais">(en)</abbr> <a rel="nofollow" class="external text" href="https://code.google.com/p/jslibs/wiki/JavascriptTips">Exemples d'utilisation avancée du langage JavaScript</a></li>
<li><a href="https://curlie.org/World/Fran%C3%A7ais/Informatique/Programmation/Langages/JavaScript/" class="extiw external" title="dmoz:World/Français/Informatique/Programmation/Langages/JavaScript/">Open Directory - JavaScript</a></li>
<li><a rel="nofollow" class="external text" href="http://fr.eloquentjavascript.net/"><i>JavaScript éloquent, Une introduction au langage de programmation JavaScript et à la programmation en général.</i></a></li>
<li><abbr class="abbr indicateur-langue" title="Langue : anglais">(en)</abbr> <a rel="nofollow" class="external text" href="http://jsfiddle.net/">JSFiddle pour tester vos codes</a></li>
<li><a rel="nofollow" class="external text" href="https://javascriptobfuscator.herokuapp.com/">JavaScript obfuscator</a></li>
<li><a rel="nofollow" class="external text" href="https://softwebtuts.blogspot.com/2019/05/javascript-deobfuscator-unpacker.html">Javascript Deobfuscator</a></li></ul>
<div class="mw-heading mw-heading3"><h3 id="Notes_et_références"><span id="Notes_et_r.C3.A9f.C3.A9rences"></span>Notes et références</h3></div>
<div class="references-small decimal" style="column-width:35em;"><ol class="references">
<li id="cite_note-wikidata-fdaa92a1fc5308e94e5ed782a2024ab0bbc4c072-1"><span class="mw-cite-backlink"><a href="#cite_ref-wikidata-fdaa92a1fc5308e94e5ed782a2024ab0bbc4c072_1-0">↑</a> </span><span class="reference-text"><span class="ouvrage">«&nbsp;<a rel="nofollow" class="external text" href="https://262.ecma-international.org/15.0/"><cite style="font-style:normal;"><span class="lang-en" lang="en">ECMAScript® 2024 Language Specification</span></cite></a>&nbsp;», <time class="nowrap" datetime="2024-06" data-sort-value="2024-06">juin 2024</time> <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2024-08-30" data-sort-value="2024-08-30">30 août 2024</time>)</small></span></span>
</li>
<li id="cite_note-wikidata-6351048ad5638805e5935d8ba81b639a34072b65-2"><span class="mw-cite-backlink"><a href="#cite_ref-wikidata-6351048ad5638805e5935d8ba81b639a34072b65_2-0">↑</a> </span><span class="reference-text"><span class="ouvrage">«&nbsp;<a rel="nofollow" class="external text" href="https://tc39.es/ecma262/"><cite style="font-style:normal;"><span class="lang-en" lang="en">ECMAScript® 2025 Language Specification</span></cite></a>&nbsp;», <time class="nowrap" datetime="2024-03-27" data-sort-value="2024-03-27">27 mars 2024</time> <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2024-04-17" data-sort-value="2024-04-17">17 avril 2024</time>)</small></span></span>
</li>
<li id="cite_note-3"><span class="mw-cite-backlink"><a href="#cite_ref-3">↑</a> </span><span class="reference-text"><a href="Douglas_Crockford" title="Douglas Crockford">Douglas Crockford</a>, dans une conférence à <a href="Yahoo!" title="Yahoo!">Yahoo!</a> <a rel="nofollow" class="external text" href="https://www.youtube.com/watch?v=RO1Wnu-xKoY&amp;list=PLPP7h_fnEnKIbyZjc5NrcLXZoRqZF4wUW">Crockford on JavaScript - Chapter 2: And Then There Was JavaScript</a>, se limite à Java, Scheme et Self comme influence direct de JavaScript</span>
</li>
<li id="cite_note-4"><span class="mw-cite-backlink"><a href="#cite_ref-4">↑</a> </span><span class="reference-text"><span class="ouvrage" id="Flanagan"><span class="ouvrage" id="David_Flanagan">David <span class="nom_auteur">Flanagan</span>, <cite class="italique">JavaScript&nbsp;: The definitive guide</cite>, <abbr class="abbr" title="sixième">6<sup>e</sup></abbr>&nbsp;<abbr class="abbr" title="édition">éd.</abbr>, <abbr class="abbr" title="page">p.</abbr>&nbsp;1<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=JavaScript&amp;rft.edition=6&amp;rft.stitle=The+definitive+guide&amp;rft.aulast=Flanagan&amp;rft.aufirst=David&amp;rft.pages=1&amp;rfr_id=info%3Asid%2Ffr.wikipedia.org%3AJavaScript"></span></span></span><blockquote>
<p>«&nbsp;JavaScript is part of the triad of technologies that all Web developers must learn: HTML to specify the content of web pages, CSS to specify the presentation of web pages, and JavaScript to specify the behaviour of web pages.&nbsp;»
</p>
</blockquote></span>
</li>
<li id="cite_note-deployedstats-5"><span class="mw-cite-backlink"><a href="#cite_ref-deployedstats_5-0">↑</a> </span><span class="reference-text"><span class="ouvrage"><abbr class="abbr indicateur-langue" title="Langue : anglais">(en)</abbr> «&nbsp;<a rel="nofollow" class="external text" href="https://w3techs.com/technologies/details/cp-javascript/all/all"><cite style="font-style:normal;" lang="en">Usage Statistics of JavaScript for Websites, March 2018</cite></a>&nbsp;», sur <span class="italique">w3techs.com</span> <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2018-10-03" data-sort-value="2018-10-03">3 octobre 2018</time>)</small></span></span>
</li>
<li id="cite_note-6"><span class="mw-cite-backlink"><a href="#cite_ref-6">↑</a> </span><span class="reference-text"><span class="ouvrage"><abbr class="abbr indicateur-langue" title="Langue : anglais">(en)</abbr> «&nbsp;<a rel="nofollow" class="external text" href="https://javascript.info/intro"><cite style="font-style:normal;" lang="en">An Introduction to JavaScript</cite></a>&nbsp;», sur <span class="italique">javascript.info</span> <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2020-07-20" data-sort-value="2020-07-20">20 juillet 2020</time>)</small></span></span>
</li>
<li id="cite_note-7"><span class="mw-cite-backlink"><a href="#cite_ref-7">↑</a> </span><span class="reference-text"><abbr class="abbr indicateur-langue" title="Langue : anglais">(en)</abbr> <a rel="nofollow" class="external free" href="http://wiki.commonjs.org/wiki/CommonJS">http://wiki.commonjs.org/wiki/CommonJS</a></span>
</li>
<li id="cite_note-8"><span class="mw-cite-backlink"><a href="#cite_ref-8">↑</a> </span><span class="reference-text"><span class="ouvrage" id="Foundation"><span class="ouvrage" id="Node.js_Foundation"><abbr class="abbr indicateur-langue" title="Langue : anglais">(en)</abbr> Node.js <span class="nom_auteur">Foundation</span>, «&nbsp;<a rel="nofollow" class="external text" href="https://nodejs.org/en/"><cite style="font-style:normal;" lang="en">Node.js</cite></a>&nbsp;», sur <span class="italique">Node.js</span> <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2017-08-05" data-sort-value="2017-08-05">5 août 2017</time>)</small></span></span></span>
</li>
<li id="cite_note-9"><span class="mw-cite-backlink"><a href="#cite_ref-9">↑</a> </span><span class="reference-text"><span class="ouvrage" id="Tung"><span class="ouvrage" id="Liam_Tung"><abbr class="abbr indicateur-langue" title="Langue : anglais">(en)</abbr> Liam <span class="nom_auteur">Tung</span>, «&nbsp;<a rel="nofollow" class="external text" href="https://www.zdnet.com/article/deno-1-0-node-js-makers-have-new-javascript-runtime-for-typescript-programming-language/"><cite style="font-style:normal;" lang="en">Deno 1.0: Node.js makers have new JavaScript runtime for TypeScript programming language</cite></a>&nbsp;», sur <span class="italique">ZDNet</span> <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2020-07-20" data-sort-value="2020-07-20">20 juillet 2020</time>)</small></span></span></span>
</li>
<li id="cite_note-10"><span class="mw-cite-backlink"><a href="#cite_ref-10">↑</a> </span><span class="reference-text"><span class="ouvrage">«&nbsp;<a rel="nofollow" class="external text" href="https://nodejs.org/en/learn/getting-started/an-introduction-to-the-npm-package-manager"><cite style="font-style:normal;">nodejs</cite></a>&nbsp;», sur <span class="italique">nodejs.org</span> <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2024-03-05" data-sort-value="2024-03-05">5 mars 2024</time>)</small></span></span>
</li>
<li id="cite_note-11"><span class="mw-cite-backlink"><a href="#cite_ref-11">↑</a> </span><span class="reference-text"><a rel="nofollow" class="external text" href="http://cgi.netscape.com/columns/techvision/innovators_be.html">TechVision: Innovators of the Net: Brendan Eich and JavaScript</a></span>
</li>
<li id="cite_note-newsrelease67-12"><span class="mw-cite-backlink"><a href="#cite_ref-newsrelease67_12-0">↑</a> </span><span class="reference-text"><abbr class="abbr indicateur-langue" title="Langue : anglais">(en)</abbr> <a rel="nofollow" class="external text" href="https://web.archive.org/web/20020606002913/http://wp.netscape.com/newsref/pr/newsrelease67.html">NETSCAPE AND SUN ANNOUNCE JAVASCRIPT, THE OPEN, CROSS-PLATFORM OBJECT SCRIPTING LANGUAGE FOR ENTERPRISE NETWORKS AND THE INTERNET</a></span>
</li>
<li id="cite_note-13"><span class="mw-cite-backlink"><a href="#cite_ref-13">↑</a> </span><span class="reference-text"><span class="ouvrage"><abbr class="abbr indicateur-langue" title="Langue : anglais">(en)</abbr> «&nbsp;<a rel="nofollow" class="external text" href="http://tsdr.uspto.gov/#caseNumber=75026640&amp;caseType=SERIAL_NO&amp;searchType=statusSearch"><cite style="font-style:normal;" lang="en">Trademark Status &amp; Document Retrieval</cite></a>&nbsp;», sur <span class="italique">tsdr.uspto.gov</span> <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2018-06-28" data-sort-value="2018-06-28">28 juin 2018</time>)</small></span></span>
</li>
<li id="cite_note-14"><span class="mw-cite-backlink"><a href="#cite_ref-14">↑</a> </span><span class="reference-text"><span class="noarchive">«&nbsp;<a rel="nofollow" class="external text" href="https://web.archive.org/web/20100528154600/http://www.sun.com/suntrademarks/">Sun Trademarks</a>&nbsp;»</span>, <time class="nowrap" datetime="2010-05-28" data-sort-value="2010-05-28">28 mai 2010</time> <small>(version du <time class="nowrap" datetime="2010-05-28" data-sort-value="2010-05-28">28 mai 2010</time> sur <i><a href="Internet_Archive" title="Internet Archive">Internet Archive</a></i>)</small></span>
</li>
<li id="cite_note-15"><span class="mw-cite-backlink"><a href="#cite_ref-15">↑</a> </span><span class="reference-text"><span class="ouvrage" id="1997"><span class="noarchive">«&nbsp;<a rel="nofollow" class="external text" href="https://tsdr.uspto.gov/#caseNumber=75026640&amp;caseType=SERIAL_NO&amp;searchType=statusSearch"><cite style="font-style:normal;">U.S. Trademark Serial No. 75026640</cite></a>&nbsp;» <small class=" cachelinks">[<a rel="nofollow" class="external text" href="https://web.archive.org/web/20210713022850/https://tsdr.uspto.gov/#caseNumber=75026640&amp;caseType=SERIAL_NO&amp;searchType=statusSearch">archive du <time class="nowrap" datetime="2021-07-13" data-sort-value="2021-07-13">13 juillet 2021</time></a>]</small></span>, sur <span class="italique">uspto.gov</span>, <a href="United_States_Patent_and_Trademark_Office" title="United States Patent and Trademark Office">United States Patent and Trademark Office</a>, <time class="nowrap" datetime="1997-05-06" data-sort-value="1997-05-06">6 mai 1997</time> <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2021-05-08" data-sort-value="2021-05-08">8 mai 2021</time>)</small></span></span>
</li>
<li id="cite_note-16"><span class="mw-cite-backlink"><a href="#cite_ref-16">↑</a> </span><span class="reference-text"><span class="ouvrage"><span class="noarchive">«&nbsp;<a rel="nofollow" class="external text" href="https://www.oracle.com/legal/trademarks.html"><cite style="font-style:normal;">Notices Légales</cite></a>&nbsp;» <small class=" cachelinks">[<a rel="nofollow" class="external text" href="https://web.archive.org/web/20210605142505/https://www.oracle.com/legal/trademarks.html">archive du <time class="nowrap" datetime="2021-06-05" data-sort-value="2021-06-05">5 juin 2021</time></a>]</small></span>, sur <span class="italique">oracle.com</span>, <a href="Oracle_Corporation" class="mw-redirect" title="Oracle Corporation">Oracle Corporation</a> <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2021-05-08" data-sort-value="2021-05-08">8 mai 2021</time>)</small></span></span>
</li>
<li id="cite_note-17"><span class="mw-cite-backlink"><a href="#cite_ref-17">↑</a> </span><span class="reference-text"><span class="ouvrage" id="2009">«&nbsp;<a rel="nofollow" class="external text" href="http://%5Binvalid%20URL%20removed%5D"><cite style="font-style:normal;">Oracle rachète Sun pour 7,4 milliards de dollars</cite></a>&nbsp;», <i>Les Échos</i>, <time class="nowrap" datetime="2009-04-21" data-sort-value="2009-04-21">21 avril 2009</time></span></span>
</li>
<li id="cite_note-18"><span class="mw-cite-backlink"><a href="#cite_ref-18">↑</a> </span><span class="reference-text"><span class="ouvrage" id="Canh2010"><span class="ouvrage" id="Tran_Canh2010"><abbr class="abbr indicateur-langue" title="Langue : anglais américain">(en-US)</abbr> Tran Canh, «&nbsp;<a rel="nofollow" class="external text" href="https://cdnhub.io/"><cite style="font-style:normal;" lang="en-us">cdnhub.io</cite></a>&nbsp;», sur <span class="italique">Technologizer by Harry McCracken</span>, <time class="nowrap" datetime="2010-09-16" data-sort-value="2010-09-16">16 septembre 2010</time> <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2024-04-10" data-sort-value="2024-04-10">10 avril 2024</time>)</small></span></span></span>
</li>
<li id="cite_note-19"><span class="mw-cite-backlink"><a href="#cite_ref-19">↑</a> </span><span class="reference-text"><span class="ouvrage">«&nbsp;<a rel="nofollow" class="external text" href="https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/The-secret-history-behind-the-success-of-npm-and-Node"><cite style="font-style:normal;">The secret history behind the success of npm and Node</cite></a>&nbsp;», sur <span class="italique">www.theserverside.com</span> <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2024-04-10" data-sort-value="2024-04-10">10 avril 2024</time>)</small></span></span>
</li>
<li id="cite_note-20"><span class="mw-cite-backlink"><a href="#cite_ref-20">↑</a> </span><span class="reference-text"><a rel="nofollow" class="external autonumber" href="https://developer.mozilla.org/fr/docs/Web/JavaScript">[1]</a></span>
</li>
<li id="cite_note-21"><span class="mw-cite-backlink"><a href="#cite_ref-21">↑</a> </span><span class="reference-text"><span class="ouvrage">«&nbsp;<a rel="nofollow" class="external text" href="https://www.ecma-international.org/publications/standards/Ecma-262.htm"><cite style="font-style:normal;">Standard ECMA-262</cite></a>&nbsp;», sur <span class="italique">www.ecma-international.org</span> <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2019-10-02" data-sort-value="2019-10-02">2 octobre 2019</time>)</small></span></span>
</li>
<li id="cite_note-22"><span class="mw-cite-backlink"><a href="#cite_ref-22">↑</a> </span><span class="reference-text"><span class="ouvrage">«&nbsp;<a rel="nofollow" class="external text" href="http://www.adsafe.org/"><cite style="font-style:normal;">Making JavaScript Safe for Advertising</cite></a>&nbsp;», ADsafe <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2013-05-26" data-sort-value="2013-05-26">26 mai 2013</time>)</small></span></span>
</li>
<li id="cite_note-23"><span class="mw-cite-backlink"><a href="#cite_ref-23">↑</a> </span><span class="reference-text"><span class="ouvrage">«&nbsp;<a rel="nofollow" class="external text" href="https://code.google.com/p/es-lab/wiki/SecureEcmaScript"><cite style="font-style:normal;">Secure ECMA Script (SES)</cite></a>&nbsp;», Code.google.com <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2013-05-26" data-sort-value="2013-05-26">26 mai 2013</time>)</small></span></span>
</li>
<li id="cite_note-24"><span class="mw-cite-backlink"><a href="#cite_ref-24">↑</a> </span><span class="reference-text"><span class="ouvrage">«&nbsp;<a rel="nofollow" class="external text" href="https://stackoverflow.com/questions/8203473/why-is-console-log-considered-better-than-alert"><cite style="font-style:normal;">Why is console.log() considered better than alert()?</cite></a>&nbsp;», sur <span class="italique">stackoverflow.com</span> <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2017-08-05" data-sort-value="2017-08-05">5 août 2017</time>)</small></span></span>
</li>
<li id="cite_note-25"><span class="mw-cite-backlink"><a href="#cite_ref-25">↑</a> </span><span class="reference-text"><span class="ouvrage"><abbr class="abbr indicateur-langue" title="Langue : anglais américain">(en-US)</abbr> «&nbsp;<a rel="nofollow" class="external text" href="https://developer.mozilla.org/en/docs/Web/API/Window"><cite style="font-style:normal;" lang="en-us">Window</cite></a>&nbsp;», sur <span class="italique">Mozilla Developer Network</span> <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2017-08-05" data-sort-value="2017-08-05">5 août 2017</time>)</small></span></span>
</li>
<li id="cite_note-26"><span class="mw-cite-backlink"><a href="#cite_ref-26">↑</a> </span><span class="reference-text"><span class="ouvrage"><abbr class="abbr indicateur-langue" title="Langue : anglais">(en)</abbr> «&nbsp;<a rel="nofollow" class="external text" href="https://nodejs.org/api/globals.html#globals_global_objects"><cite style="font-style:normal;" lang="en">Global Objects | Node.js v8.2.1 Documentation</cite></a>&nbsp;», sur <span class="italique">nodejs.org</span> <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2017-08-05" data-sort-value="2017-08-05">5 août 2017</time>)</small></span></span>
</li>
<li id="cite_note-27"><span class="mw-cite-backlink"><a href="#cite_ref-27">↑</a> </span><span class="reference-text"><span class="ouvrage"><abbr class="abbr indicateur-langue" title="Langue : anglais">(en)</abbr> «&nbsp;<a rel="nofollow" class="external text" href="http://blogs.msdn.com/ie/archive/2008/09/10/native-json-in-ie8.aspx"><cite style="font-style:normal;" lang="en">IEBlog</cite></a>&nbsp;», sur <span class="italique">msdn.com</span> <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2020-09-29" data-sort-value="2020-09-29">29 septembre 2020</time>)</small></span>.</span>
</li>
<li id="cite_note-28"><span class="mw-cite-backlink"><a href="#cite_ref-28">↑</a> </span><span class="reference-text">Voir <a rel="nofollow" class="external text" href="https://developer.mozilla.org/fr/docs/Introduction_au_shell_JavaScript">Introduction au shell JavaScript</a></span>
</li>
<li id="cite_note-29"><span class="mw-cite-backlink"><a href="#cite_ref-29">↑</a> </span><span class="reference-text"><span class="ouvrage" id="2023"><abbr class="abbr indicateur-langue" title="Langue : anglais américain">(en-US)</abbr> «&nbsp;<a rel="nofollow" class="external text" href="https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/Variables"><cite style="font-style:normal;" lang="en-us">Storing the information you need — Variables - Learn web development | MDN</cite></a>&nbsp;», sur <span class="italique">developer.mozilla.org</span>, <time class="nowrap" datetime="2023-05-09" data-sort-value="2023-05-09">9 mai 2023</time> <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2023-06-22" data-sort-value="2023-06-22">22 juin 2023</time>)</small></span></span>
</li>
<li id="cite_note-30"><span class="mw-cite-backlink"><a href="#cite_ref-30">↑</a> </span><span class="reference-text"><span class="ouvrage" id="Alman2010"><span class="ouvrage" id="Ben_Alman2010"><abbr class="abbr indicateur-langue" title="Langue : anglais">(en)</abbr> Ben <span class="nom_auteur">Alman</span>, «&nbsp;<a rel="nofollow" class="external text" href="http://benalman.com/news/2010/11/immediately-invoked-function-expression/"><cite style="font-style:normal;" lang="en">Immediately-Invoked Function Expression (IIFE)</cite></a>&nbsp;», sur <span class="italique">benalman.com</span>, <time class="nowrap" datetime="2010-11-15" data-sort-value="2010-11-15">15 novembre 2010</time> <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2016-05-14" data-sort-value="2016-05-14">14 mai 2016</time>)</small></span></span></span>
</li>
<li id="cite_note-31"><span class="mw-cite-backlink"><a href="#cite_ref-31">↑</a> </span><span class="reference-text"><span class="ouvrage" id="Crockford"><span class="ouvrage" id="Douglas_Crockford"><abbr class="abbr indicateur-langue" title="Langue : anglais">(en)</abbr> Douglas <span class="nom_auteur">Crockford</span>, «&nbsp;<a rel="nofollow" class="external text" href="http://javascript.crockford.com/code.html"><cite style="font-style:normal;" lang="en">Code Conventions for the JavaScript Programming Language</cite></a>&nbsp;», sur <span class="italique">javascript.crockford.com</span> <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2016-05-14" data-sort-value="2016-05-14">14 mai 2016</time>)</small></span></span></span>
</li>
<li id="cite_note-32"><span class="mw-cite-backlink"><a href="#cite_ref-32">↑</a> </span><span class="reference-text">Cet exemple est donné page 25 par&nbsp;: <i>JavaScript - The Definitive Guide</i>, Fourth Edition, David Flanagan, éditions <a href="O'Reilly_Media" title="O'Reilly Media">O'Reilly Media</a>, Sebastopol, Californie.</span>
</li>
</ol>
</div>
<div class="navbox-container" style="clear:both;">



</div>
<ul id="bandeau-portail" class="bandeau-portail"><li><span class="bandeau-portail-element"><span class="bandeau-portail-icone"><span class="noviewer" typeof="mw:File"></span></span> <span class="bandeau-portail-texte">Portail de la programmation informatique</span> </span></li> </ul></div><!--htdig_noindex--><div><div class="zim-footer">
Cet article est issu de <a class="external text" title="Dernière modification le 2025-06-10" href="https://fr.wikipedia.org/wiki/?title=JavaScript&amp;oldid=226403340">Wikipédia</a>. Sauf mention contraire, le texte est disponible sous <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.fr">Creative Commons Attribution-Share Alike 4.0</a>. Des conditions supplémentaires peuvent s’appliquer aux fichiers multimédias.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>
<script src="./_webp_/webpHandler.js"></script>

</body></html>